Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
jQuery Articles
Found 413 articles
What is $(window).load() method in jQuery?
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 MoreHow to animate a change in background color using jQuery on mouseover?
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 MoreHow to center a div on the screen using jQuery?
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 MoreHow to clear HTML form fields with jQuery?
With jQuery, you can easily clear HTML form fields. For this, jQuery: reset Selector is used. This will clear the HTML form fields.ExampleYou can try to run the following code to clear form fields with jQuery − $(document).ready(function(){ $(":reset").css("background-color", "#F98700"); }); Student Name Student Subject
Read MoreAlign the components with Bootstrap
To align the components like nav links, forms, buttons, or text to left or right in a navbar using the utility classes .navbar-left or .navbar-right. Both classes will add a CSS float in the specified direction.ExampleYou can try to run the following code to align components Bootstrap Example Alignment Java jmeter EJB Jasper Report Separated link One more separated link Left align-Submit Button Left align-Text Java jmeter EJB Jasper Report Separated link One more separated link Right align-Submit Button Right align-Text
Read MoreHow to exclude first and second element from jQuery selector?
To exclude first and second element from jQuery, use the slice() method.ExampleYou can try to run the following code to exclude first and element from jQuery: $(document).ready(function(){ $('p').slice(2).css('font-size', '24px'); }); Java C++ Ruby Groovy
Read MoreHow to check which key has been pressed using jQuery?
To check which key has been pressed, use the onkeydown attribute.ExampleYou can try to run the following code to get which key is pressed: Press a key in the below box to get which key is pressed. function demoFunction(event) { var a = event.key; document.getElementById("test").innerHTML = "You've pressed the key: " + a; }
Read MoreHow to disable right click using jQuery?
To disable right click on a page, use the jQuery bind() method.ExampleYou can try to run the following code to learn how to disable right click: $(document).ready(function(){ $(document).bind("contextmenu",function(e){ return false; }); }); Right click is disabled on this page.
Read MoreHow to get the input value of the first matched element using jQuery?
To get the input value of the first matched element using jQuery, use the .first() method.ExampleYou can try to run the following code to get the input value of the first matched element using jQuery − $(document).ready(function(){ $( "li" ).first().css( "background-color", "blue" ); }); One Two Three Four
Read MoreWhat is the difference between switchClass() and toggleClass() methods in jQuery?
The switchClass() is used to switch class from an element. Use it, to replace one class with another. Add jQuery UI library to the web page to use switchClass().ExampleYou can try to run the following code to learn how to work with switch class − $(document).ready(function(){ $("a").click(function(){ $("a.active").removeClass("active"); $(this).addClass("active"); }); }); ...
Read More