Web Development Articles

Found 8,006 articles

What is $(window).load() method in jQuery?

David Meador
David Meador
Updated on 11-Mar-2026 5K+ Views

The code which gets included inside $( window ).on( "load", function() { ... }) runs only once the entire page is ready (not only DOM).Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.ExampleYou can try to run the following code to learn how to use $(window).load() method in jQuery − $(document).ready(function(){    $("img").load(function(){      alert("Image successfully loaded.");    }); }); Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.

Read More

How to animate a change in background color using jQuery on mouseover?

Kristi Castro
Kristi Castro
Updated on 11-Mar-2026 855 Views

To change background color, use the mouseenter event. The background color change when you place mouse cursor:mouseenter: function(){    $(this).css("background-color", "gray"); }The mouse cursor is placed on the following element:Click and move the mouse pointer to change the background color.You can try to run the following code to learn how to animate a change in background color on mouseover:Example               $(document).ready(function(){          $("body").on({             mouseenter: function(){                $(this).css("background-color", "gray");             },                 mouseleave: function(){                $(this).css("background-color", "red");             },              });       });        Click and move the mouse pointer to change the background color.

Read More

How to center a div on the screen using jQuery?

Kristi Castro
Kristi Castro
Updated on 11-Mar-2026 762 Views

To center a div on the screen, use the jQuery centering function jQuery.fn.center. You can try to run the following code to learn how to center a div on the screen:Example               $(document).ready(function(){       jQuery.fn.center = function(parent) {         if (parent) {           parent = this.parent();         } else {           parent = window;         }       this.css({        "position": "absolute",        "top": ((($(parent).height() - ...

Read More

How to add a colored border to a button with CSS?

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 1K+ Views

To add colored border, use the CSS border property.ExampleYou can try to run the following code to add a colored border.                    .button {             background-color: yellow;             color: black;             text-align: center;             font-size: 15px;             padding: 20px;             border-radius: 15px;             border: 3px dashed blue;          }                     Result       Click below for result:       Result    

Read More

HTML DOM Input Email autocomplete Property

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 213 Views

The HTML DOM Input Email autocomplete property sets/returns whether autocomplete is enabled or disabled. If enabled, it shows previously typed values.SyntaxFollowing is the syntax −Returning value - on/offinputEmailObject.autocompleteSetting autocomplete to valueinputEmailObject.autocomplete = valueValuesHere, “value” can be the following −valueDetailsonIt defines that input has autocomplete enabled, it is also the default.offIt defines that input autocomplete attribute is disabled.ExampleLet us see an example of Input Email autocomplete property − Input Email autocomplete    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: ...

Read More

Set Flex Items into equal width columns with Bootstrap

Amit Diwan
Amit Diwan
Updated on 11-Mar-2026 5K+ Views

To set flex items to be of equal width column, use the flex-fill class. The class displays the items as equal width. In the below example screenshot, you can see that we have four flex items with equal width columns −The flex-fill class is used for every flex items and in this way, we can set equal width. Below, we have two flex items − Example 1 Example 2 Example       Bootstrap Example                                   With flex-fill               Example 1         Example 2         Example 3         Example 4             Without .flex-fill:               Example 1         Example 2         Example 3         Example 4              

Read More

HTML DOM Input Month readOnly Property

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 167 Views

The HTML DOM input month readOnly property returns and modify whether the input month field is read-only or not in an HTML document.SyntaxFollowing is the syntax −1. Returning readOnlyobject.readOnly2. Modifying readOnlyobject.readOnly = true | falseExample    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)       center/cover no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.1rem;    }    input{       display:block;       width:35%;     ...

Read More

Traversing Diagonally in a matrix in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 924 Views

Problem:We are required to write a JavaScript function that takes in a square matrix (an array of arrays having the same number of rows and columns). The function should traverse diagonally through that array of array and prepare a new array of elements placed in that order it encountered while traversing.For example, if the input to the function is −const arr = [    [1, 2, 3],    [4, 5, 6],    [7, 8, 9] ];Then the output should be −const output = [1, 2, 4, 7, 5, 3, 6, 8, 9];Exampleconst arr = [    [1, 2, 3],   ...

Read More

Common element with least index sum in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 234 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of literals, arr1 and arr2, as the first and the second argument.Our function should find out the common element in arr1 and arr2 with the least list index sum. If there is a choice tie between answers, we should output all of them with no order requirement.For example, if the input to the function is−const arr1 = ['a', 'b', 'c', 'd']; const arr2 = ['d', 'a', 'c'];Then the output should be −const output = ['a'];Output ExplanationSince 'd' and 'a' are common in both the arrays the index ...

Read More

JavaScript One fourth element in array

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 179 Views

ProblemJavaScript function that takes in an array of integers sorted in increasing order, arr.There is exactly one integer in the array that occurs more than one fourth times (25%) of the times, our function should return that number.For example, if the input to the function is −const arr = [3, 5, 5, 7, 7, 7, 7, 8, 9];Then the output should be −const output = 7;Exampleconst arr = [3, 5, 5, 7, 7, 7, 7, 8, 9]; const oneFourthElement = (arr = []) => {    const len = arr.length / 4;    const search = (left, right, target, direction = 'left') => {       let index = -1       while (left

Read More
Showing 1–10 of 8,006 articles
« Prev 1 2 3 4 5 801 Next »
Advertisements