Home >Web Front-end >JS Tutorial >jQuery uses the attr() method to set multiple attribute values at the same time_jquery
The example in this article describes the use of jQuery to use the attr() method to set multiple attribute values at the same time. Share it with everyone for your reference. The details are as follows:
The following demonstration example allows you to modify links and prompts by clicking a button.
<!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("#w3s").attr({ "href" : "http://www.jb51.net/list/list_172_1.htm", "title" : "jb51.net" }); }); }); </script> </head> <body> <p><a href="http://www.jb51.net/list/list_172_1.htm" id="w3s">jb51.net</a></p> <button>点此改变链接与提示</button> <p>鼠标滑过链接即可看到链接与提示信息已被更改.</p> </body> </html>
I hope this article will be helpful to everyone’s jQuery programming.