Javascript examples for jQuery Method and Property:attr
The following example demonstrates how to set both the href and title attributes at the same time:
<!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" });/*from w w w. j a va 2 s . com*/ }); }); </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>