Articles on Trending Technologies

Technical articles with clear explanations and examples

How to remove all style attributes using jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 9K+ Views

To remove an attribute from each tag using jQuery, use the removeAttr() method and use the Universal Selector. Let us see how to use the method to remove all style attribute. Use the universal selector also to select all the elements.You can try to run the following code to learn how to remove all style attributes using jQuery −Example $(document).ready(function(){   $("button").click(function(){     $("h1").removeAttr("style");   }); }); This is heading This is demo text. This is heading This is demo text. Remove Click above to remove style attribute from all h1 elements.

Read More

How to add and remove HTML attributes with jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 746 Views

To add and remove HTML attributes with jQuery, use the addClass() and removeClass() method.You can try to run the following code to add and remove HTML attributes with jQuery −Example           jQuery Example                      $(document).ready(function(){                      $( '#add' ).click( function () {                $('#page_navigation1').addClass( 'blue-class' );                    });                      $( '#remove' ).click( function () {                        $('#page_navigation1').removeClass( 'blue-class' );                    });              });                                  .blue-class {            background-color: blue;            font-size: 30px;          }              Demo    Add    Remove

Read More

How should I initialize jQuery in a web page?

David Meador
David Meador
Updated on 11-Mar-2026 2K+ Views

To initialize jQuery in a web easy is quite easy. You can try to run the following code to learn how to initialize jQuery in a web page. We’re using Google CDN to add jQuery. Microsoft CDN is also available for the same purpose of adding jQuery library to HTML.Example           jQuery Function                      $(document).ready(function() {             $("div").click(function() {alert("Welcome to Tutorialspoint!");});          });                                  Click on this to see a dialogue box.          

Read More

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

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 208 Views

Yes, it is possible to use $(this) and universal selector (*) with jQuery. Let’s see how to do it. You can try to run the following code to learn how to use this and universal selector with jQuery:Example           jQuery Universal Selector                          $(document).ready(function() {             $('*', this).css("background-color", "yellow");          });                                          This is first division of the DOM.                      This is second division of the DOM.          

Read More

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

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

To select a single element which matches with the given ID using jQuery, use the element id selector. Here’s how,$('#elementid')You can try to run the following code to learn how to select a single element which matches with the given ID using jQuery −Example           Selector Example                          $(document).ready(function() {             /* This would select second division only*/             $("#div2").css("background-color", "yellow");          });                                          This is first division of the DOM.                      This is second division of the DOM.                      This is third division of the DOM          

Read More

How to get an attribute value in jQuery?

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

To get an attribute value in jQuery is quite easy. For this, use the jQuery attr() method. You can try to run the following code to learn how to get an attribute value in jQuery −Example           jQuery Example                   $(document).ready(function(){          $("button").click(function(){             alert($("img").attr("height"));          });       });                               Get the height        

Read More

How to get the value of src attribute in jQuery?

Amit D
Amit D
Updated on 11-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. Let’s first see how we can add jQuery −You can try to run the following code to learn how to get the value of src attribute in jQuery −Example           Selector Example                      $(document).ready(function() {             alert($('#myimg').attr('src'));          });                     Logo          

Read More

How to change the value of an attribute using jQuery?

Ricky Barnes
Ricky Barnes
Updated on 11-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. In the example, we will change the attribute value tutorialspoint.com to tutorialspoint.com/java.You can try to run the following code to learn how to change the value of an attribute using jQuery −Example           Selector Example                    $(document).ready(function(){          $("button").click(function(){            $("#tpoint").attr("href", "https://www.tutorialspoint.com/java");          });        });                     tutorialspoint.com       Change attribute value       The value of above link will change on clicking the above button. Check before and after clicking the link.    

Read More

How to add and remove a class to an anchor tag with jQuery?

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

To add and remove a class to an anchor tag, use the toggleClass. Using it you can add and remove a class on a click.You can try to run the following code to learn how to add and remove a class to an anchor tag with jQuery −Example                         $(document).ready(function(){          $("#mylink").click(function (e) {             e.preventDefault();                     $(this).toggleClass("selected");            });         });                     .selected {            color: red;         }                     Click me       The above will add and remove class (change color) on click.    

Read More

How to add a title in anchor tag using jQuery?

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

To add a title in anchor tag in jQuery, use the prop() method. The prop() method is used to set properties and values of the selected elements.You can try to run the following code to learn how to add a title in anchor tag using jQuery −Example                        $(document).ready(function(){          $("#button1").click(function(){             $('.myClass').prop('title', 'This is your new title');             var myTitle = $('.myClass').prop('title');             alert(myTitle);          });        });                                        Get Title          

Read More
Showing 1–10 of 61,248 articles
« Prev 1 2 3 4 5 6125 Next »
Advertisements