jQuery Articles

Page 10 of 42

What are jQuery events .load(), .ready(), .unload()?

Amit D
Amit D
Updated on 13-Mar-2026 1K+ Views

jQuery load() method The .load() method is used to attach an event handler to the load event. This event occurs when an element and all its child elements have completely loaded, including images, scripts, and stylesheets. Example You can try to run the following code to learn how to work with jQuery .load() method − Note: The .load() method was deprecated in jQuery 1.8 and finally removed in jQuery 3.0. To run the following code, add jQuery ...

Read More

How to trigger the same function with jQuery multiple events?

Amit D
Amit D
Updated on 13-Mar-2026 5K+ Views

To trigger the same function with multiple events, use the jQuery on() method with multiple events such as click, dblclick, mouseenter, mouseleave, hover, etc. The on() method provides a flexible way to attach event handlers to elements. You can bind multiple events to the same element using an object notation where each property represents an event type and its corresponding handler function. Example You can try to run the following code to learn how to work the same function with jQuery multiple events − ...

Read More

How to check which key has been pressed using jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 851 Views

To check which key has been pressed in jQuery, you can use the keydown, keyup, or keypress event handlers. The most common approach is to use the keydown event, which fires when a key is pressed down. Using jQuery Event Handlers jQuery provides several methods to detect key presses. You can bind event listeners to elements and capture the key information from the event object. The event.key property returns the value of the key pressed. Example You can try ...

Read More

How to prevent the browser from executing the default action in jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 874 Views

To prevent the browser from executing the default action in jQuery, use the preventDefault() method. The preventDefault() method prevents the browser from executing the default action associated with an event, such as following a link, submitting a form, or checking a checkbox. Example The following example demonstrates how to prevent a link from navigating to its href destination. You can also use the method isDefaultPrevented() to know whether this method was ever called on that event object − jQuery preventDefault() ...

Read More

How to get attribute of an element when using the 'click' event in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 3K+ Views

To get attribute of an element, use the attr() method in jQuery. The attr() method retrieves the value of an attribute from the first element in the matched set of elements. When used with click events, it allows you to dynamically access element attributes when user interactions occur. Example You can try to run the following code to get attribute of an element using the 'click' event − $(document).ready(function(){ $("button").click(function(){ ...

Read More

How to check the element type of an event target with jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 2K+ Views

To check the element type of an event target, we use the is() method. The is() method checks the current matched set of elements against a selector and returns true if at least one of these elements matches the given arguments. Example You can try to run the following code to check the element type − $(document).ready(function(){ $("ul").click(function(event) { ...

Read More

How to handle a mouse right click event using jQuery?

David Meador
David Meador
Updated on 13-Mar-2026 4K+ Views

To handle a mouse right click event, use the mousedown() jQuery method. Mouse left, right and middle click can also be captured using the same method. The event.which property helps identify which mouse button was clicked: 1 for left, 2 for middle, and 3 for right mouse button. Example You can try to run the following code to learn how to handle a mouse right click event − $(document).ready(function(){ ...

Read More

How to handle a double click event using jQuery?

David Meador
David Meador
Updated on 13-Mar-2026 1K+ Views

To handle a double click event using jQuery, use the dblclick() event. When an element is double clicked, this event occurs. The dblclick() method triggers the double-click event or attaches a function to run when a double-click event occurs on the selected elements. Syntax The basic syntax for the dblclick() method is − $(selector).dblclick(function) Where function is optional and specifies the function to run when the double-click event occurs. Example You can try to run the following code to learn how to handle double click event using jQuery − ...

Read More

How to handle a link click event using jQuery?

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

To handle a click event using jQuery, use the click() method. This method allows you to attach a function that executes when a user clicks on a link or any other element. You can try to run the following code to handle a link click event using jQuery − Example Here's a complete example that demonstrates handling link click events − $(document).ready(function(){ $("a").click(function(){ ...

Read More

How can I remove everything inside of a <div> using jQuery?

David Meador
David Meador
Updated on 13-Mar-2026 702 Views

To remove everything inside a div element, you can use jQuery's empty() method or remove() method. The empty() method removes all child elements while keeping the div itself, whereas remove() removes the entire div element including its contents. Using empty() Method The empty() method is the most appropriate choice when you want to clear the contents inside a div while preserving the div element itself − $(document).ready(function(){ ...

Read More
Showing 91–100 of 413 articles
« Prev 1 8 9 10 11 12 42 Next »
Advertisements