jQuery Articles

Page 23 of 42

How to change the value of an attribute using jQuery?

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

The jQuery attr() method is used to get the value of an attribute. It can also be used to change the value of an attribute by providing a new value as the second parameter. In the example below, we will change the attribute value from tutorialspoint.com to tutorialspoint.com/java. The syntax for changing an attribute value is: $(selector).attr(attributeName, newValue) You can try to run the following code to learn how to change the value of an attribute using jQuery − ...

Read More

How to get the value of src attribute in jQuery?

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

To get the value of src attribute in jQuery is quite easy. We will get the src attribute of the img tag. This attribute has the URL of the image and can be retrieved using jQuery's attr() method. The attr() method in jQuery is used to get the value of an attribute for the first element in the set of matched elements. When we pass 'src' as a parameter to this method, it returns the source URL of the image. Example You can try to run the following code to learn how to get the value of ...

Read More

How to get an attribute value in jQuery?

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

To get an attribute value in jQuery is quite easy. For this, use the jQuery attr() method. The attr() method retrieves the value of the specified attribute from the first matched element. Syntax The basic syntax for getting an attribute value is − $(selector).attr(attributeName) Where attributeName is the name of the attribute whose value you want to retrieve. Example You can try to run the following code to learn how to get an attribute value in jQuery − jQuery Example ...

Read More

How to select a single element which matches the given ID using jQuery?

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

To select a single element which matches with the given ID using jQuery, use the element id selector. The syntax is straightforward − $('#elementid') The # symbol followed by the element's ID allows jQuery to locate and select that specific element from the DOM. Since IDs are unique within an HTML document, this selector will always return a single element. Example You can try to run the following code to learn how to select a single element which matches with the given ID using jQuery − ...

Read More

Is it possible to use $(this) and universal selector (*) with jQuery?

Alex Onsman
Alex Onsman
Updated on 13-Mar-2026 215 Views

Yes, it is possible to use $(this) and universal selector (*) with jQuery. The universal selector selects all elements in the DOM, while $(this) refers to the current element in context. When combined, they can be used to select all elements within a specific scope. The syntax $('*', this) selects all elements within the context of the current element, where this serves as the context parameter. Example You can try to run the following code to learn how to use $(this) and universal selector with jQuery − ...

Read More

How to combine a class selector and an attribute selector with jQuery?

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

A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. We can easily combine a class selector and an attribute selector with jQuery. To combine selectors, we use the syntax .classname[attribute="value"] where there is no space between the class selector and the attribute selector. This creates a compound selector that matches elements having both the specified class and the specified attribute value. You can try to run the following code to learn how to combine a class selector and an attribute selector with jQuery ...

Read More

How can I get the ID of an DOM element using jQuery?

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

In jQuery, the attr() method is used to get the id attribute of the first matching element. This method allows you to retrieve any attribute value from a DOM element. Syntax The basic syntax to get an element's ID using jQuery is − $(selector).attr("id") Where selector is the jQuery selector that identifies the element whose ID you want to retrieve. Example Here's a complete example that demonstrates how to get the ID of a DOM element when a button is clicked − Getting DOM ...

Read More

How can I know which radio button is selected via jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 313 Views

Use the jQuery val() method to get the value of the selected radio button. The :checked selector in combination with input:radio helps identify which radio button is currently selected in a group. Example You can try to run the following code to learn how to know which radio button is selected via jQuery − jQuery Selector ...

Read More

How do I check if an element is hidden in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 282 Views

Using jQuery, you can detect if a specific element in the page is hidden or visible with :visible and :hidden selectors. jQuery provides several methods to check element visibility, with is(':visible') and is(':hidden') being the most commonly used approaches. Methods to Check Element Visibility There are two primary selectors you can use − :visible − Selects elements that are visible (display is not 'none', visibility is not 'hidden', and opacity is not 0) :hidden − Selects ...

Read More

How to select element with specific class and title attribute using jQuery?

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

If your element is having a class and title attribute, you can select it with jQuery using attribute selectors combined with class selectors. The syntax combines the class selector (dot notation) with the attribute selector in square brackets. You can try to run the following code to learn how to select element with specific class and 'title' attribute using jQuery. Syntax The basic syntax for selecting elements with both class and title attribute is − $(".className[title='titleValue']") Example Here's a complete example that demonstrates how to select and style elements with specific class and ...

Read More
Showing 221–230 of 413 articles
« Prev 1 21 22 23 24 25 42 Next »
Advertisements