How to change the value of an attribute using jQuery?

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
      
      
   
   
      

tutorialspoint.com

           

The value of above link will change on clicking the above button. Check before and after clicking the link.

   
Updated on: 2026-03-11T20:54:41+05:30

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements