Javascript examples for jQuery Method and Property:attr
Change the href attribute in a link
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#w3s").attr({ "href" : "http://java2s.com", "title" : "jQuery Tutorial" });/*www.j a va 2 s . c o m*/ }); }); </script> </head> <body> <p><a href="http://java2s.com" title="some title" id="myId">java2s.com</a></p> <button>Change href and title</button> </body> </html>