jQuery Articles

Page 6 of 42

How to check if event exists on element in jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 5K+ Views

To check if event exists on element in jQuery, you need to examine the existing events bound to that element. jQuery provides methods to access the event data stored internally for DOM elements. Here, I have set a div element − This is demo text. Click here! When you click the div, an alert is generated. To check if events exist on this element, we use $._data() method to access the internal event data and verify if any events are bound to the element. $("#demo").click(function() { alert("Does ...

Read More

How to enable and disable submit button using jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 1K+ Views

To enable and disable submit button, use the jQuery prop() method. The prop() method gets or sets properties and values of the selected elements. When used with the disabled property, it can control whether a button is clickable or not. Syntax Here's the basic syntax for enabling and disabling buttons − // To disable a button $(selector).prop('disabled', true); // To enable a button $(selector).prop('disabled', false); Example You can try to run the following code to enable and disable submit button using jQuery − ...

Read More

Can I submit form with multiple submit buttons using jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 3K+ Views

Yes, you can submit forms with multiple submit buttons using jQuery. Attach a custom click handler to all the buttons and then check which button is clicked. When working with multiple submit buttons, you need to prevent the default form submission behavior and implement custom logic to determine which button was pressed. This allows you to perform different actions based on the specific button clicked. Example The following example demonstrates how to handle multiple submit buttons using jQuery − ...

Read More

How to create div dynamically using jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 2K+ Views

To create a div dynamically using jQuery, you can use several methods such as html(), append(), or create elements with the $() constructor. The html() method replaces the existing content, while append() adds new content to existing elements. Example 1: Using html() Method The following example shows how to create a div dynamically using the html() method on button click − $(document).ready(function(){ $("button").click(function(){ ...

Read More

How to get the content of a textarea using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 749 Views

In jQuery, you can easily retrieve the content of a textarea element using the val() method. This method returns the current value of form elements, including textareas. Basic Syntax The basic syntax to get textarea content is − var content = $("#textareaId").val(); Example Here is a complete example using one textarea and one button. The textarea is used for user input, then clicking the button displays the value in an alert box − ...

Read More

How to detect Ctrl+Enter in textarea using jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 123 Views

Detecting Ctrl+Enter key combination in a textarea is a common requirement for web applications, especially when implementing features like quick form submission or chat interfaces. Using jQuery, we can easily capture this key combination by listening to keyboard events and checking for the specific key codes along with modifier keys. Method Using keydown Event The most effective approach is to use jQuery's keydown event handler to detect when the user presses Ctrl+Enter. We need to check for the Enter key (key code 13) while the Ctrl key is pressed. Example Here's a complete example that detects ...

Read More

How to detect pressing Enter on keyboard using jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 401 Views

To detect pressing Enter on keyboard, use the keyup() function with keyCode. The Enter key has a keyCode of 13, which can be checked when the keyup event is triggered. You can try to run the following code to learn how to detect pressing Enter on keyboard using jQuery − Example $(document).ready(function(){ $('textarea').bind("enterKey", function(e){ ...

Read More

How to get current URL in jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 4K+ Views

For getting the current URL in jQuery, you can use the attr() method with the location object or the native JavaScript window.location property. Both methods provide access to the complete URL of the current page. Methods to Get Current URL There are two main approaches − 1. Using jQuery's attr() method: $(location).attr('href') returns the complete URL as a string. 2. Using window.location: The native JavaScript window.location object provides access to the current URL and its components. Example Here's a complete example demonstrating both methods − ...

Read More

How to select ALL children (in any level) from a parent in jQuery?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 1K+ Views

To select all children from a parent in jQuery, use the find() method. The find() method searches through all descendants of the selected elements and returns all matching elements, regardless of their nesting level. The syntax is $(parent).find('*') where the asterisk (*) acts as a universal selector to match all child elements at any depth. Example You can try to run the following code to select ALL children in any level − .myclass * { ...

Read More

How to increase the duration of jQuery effects?

Kristi Castro
Kristi Castro
Updated on 13-Mar-2026 385 Views

To increase the duration of jQuery effects, set the optional speed parameter. The values include slow, fast, or specific milliseconds. The slow value provides a longer duration, while fast provides a shorter duration compared to the default. Let us see an example with the fadeIn() jQuery method. The fadeIn() method fades in all matched elements by adjusting their opacity and firing an optional callback after completion. Here is the description of all the parameters used by this method − speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") ...

Read More
Showing 51–60 of 413 articles
« Prev 1 4 5 6 7 8 42 Next »
Advertisements