jQuery Articles

Page 2 of 42

How to make jQuery attribute selector case insensitive?

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

To make jQuery attribute selector case insensitive, create two buttons and manipulate the input with attribute selector.ExampleYou can try to run the following code to make jQuery attribute selector case insensitive:                          $(document).ready(function(){            $("button").click(function(){               $( "input[name*='myclass' i]" ).css("background-color", "yellow");            });                $("#insensitive").click(function(){               $( "input[name*='myclass' i]" ).css("background-color", "blue");            });            // myclass input blue            $("#sensitive").click(function(){               $( "input[name*='myclass']" ).css("background-color", "blue");            });          });                                       Case insensitive       Case sensitive    

Read More

How to use OR Operation in jQuery Attribute Selectors?

Amit D
Amit D
Updated on 11-Mar-2026 262 Views

Use comma to work with OR operation in jQuery Attribute Selector.ExampleYou can try to run the following code to learn how to use OR operation in jQuery attribute selector:                          $(document).ready(function(){            $('[myattr=demo][myid="sub1"],[myattr=demo][myid="sub3"]').css("background-color", "yellow");          });                     Java       HTML       Ruby    

Read More

How to find an element based on a data-attribute value in jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 747 Views

To find an element based on a data-attribute value using jQuery is quite easy.ExampleYou can try to run the following code to learn how to find an element based on a data-attribute value using jQuery:    $(document).ready(function() {       $('[data-slide="2"]').addClass('demo');    }); .demo {     font-size: 200%;     color: green; } One Two Three

Read More

How to use *= operator in jQuery attribute selector?

Amit D
Amit D
Updated on 11-Mar-2026 562 Views

The *= operator is used to filter elements for attribute containing the given value.ExampleYou can try to run the following code to learn how to *= operator to filter attributes on the basis of text: $(document).ready(function(){    $( "div[myattr*='subject']" ).css("background-color", "yellow");     }); Java HTML Ruby

Read More

How do I find a certain attribute exists or not for a selected item in jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 293 Views

To find a certain attribute exists or not for a selected item in jQuery, use the hasAttribute() method.ExampleYou can try to run the following code to learn how to find a certain attribute exists or not:                          $(document).ready(function(){             $('button').on('click', function() {                 if (this.hasAttribute("myattr")) {                    alert('True - myattr attribute exists')                 } else {                    alert('False - myattr attribute does not exist')                 }             })          });                           Button One                   Button Two          

Read More

How can I add an attribute into specific HTML tags in jQuery?

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

Use the attr() method to add an attribute into specific HTML tags in jQuery.ExampleYou can try to run the following code to learn how to add an attribute into specific HTML tags:   $(document).ready(function(){       $(document).ready(function(){          $("button.button1").attr("myid", "myvalue");            $('button').on('click', function() {                     if (this.hasAttribute("myid")) {                alert('True: The new attribute added successfully.')             } else {                alert('False')             }           })       });   });           Button 1    

Read More

How to use jQuery to get the value of HTML attribute of elements?

Amit D
Amit D
Updated on 11-Mar-2026 327 Views

To get the value of html attribute, use the val() method.ExampleYou can try to run the following code to learn how to use jQuery to get the value of HTML attribute of elements:                          $(document).ready(function() {             $("#buttonSet").click(function () {                           $("#buttonGet").removeAttr('disabled');             });             $("#buttonGet").click(function () {               $("#result").html(               $("#txtBox").val() + "" +               $("input:radio[name=rd]:checked").val()             );          });          });                     Name                   Gender       Male       Female                            

Read More

How to set “checked” for a checkbox with jQuery?

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

Use the checked attribute to set the checkbox with jQuery. Also, the prop() method is used to get the property value.ExampleYou can try to run the following code to learn how to set checked for a checkbox:   jQuery Example     b {      color: green;   }       Check/ Uncheck this checkbox   $( "input" ).change(function() {   var $input = $( this );   $( "p" ).html(     ".attr( "checked" ): " + $input.attr( "checked" ) + "" +     ".prop( "checked" ): " + $input.prop( "checked" ) + "" +     ".is( ":checked" ): " + $input.is( ":checked" ) + "" ); }).change();  

Read More

How do we use # in jQuery Attribute Selector?

Amit D
Amit D
Updated on 11-Mar-2026 383 Views

To use # in jQuery attribute selector, include # under *= . This will find the attribute with #.ExampleYou can try to run the following code to learn how to use # in jQuery attribute selector:     $(document).ready(function()  {        $( "div[myattr*='#']" ).css("background-color", "yellow");     }); Java HTML Ruby

Read More

How do we use jQuery Attribute selector with a period?

Amit D
Amit D
Updated on 11-Mar-2026 338 Views

jQuery Attribute selector is used to select elements with the specified attribute and value. You can easily use it with a period (.) or a hash (#).ExampleYou can try to run the following code to learn how to use jQuery selector with a period: $(document).ready(function(){    $( "div[myattr*='.']" ).css("background-color", "yellow");   }); Java HTML Ruby

Read More
Showing 11–20 of 413 articles
« Prev 1 2 3 4 5 42 Next »
Advertisements