[JavaScript] jQuery通过attr()方法同时设置多个属性值 →→→→→进入此内容的聊天室

来自 , 2021-02-05, 写在 JavaScript, 查看 145 次.
URL http://www.code666.cn/view/263fc48a
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
  5. </script>
  6. <script>
  7. $(document).ready(function(){
  8.   $("button").click(function(){
  9.     $("#w3s").attr({
  10.       "href" : "http://www.sharejs.com/jquery",
  11.       "title" : "sharejs.com"
  12.     });
  13.   });
  14. });
  15. </script>
  16. </head>
  17.  
  18. <body>
  19. <p><a href="http://www.sharejs.com" id="w3s">sharejs.com</a></p>
  20. <button>Change href and title</button>
  21. <p>Mouse over the link to see that the href attribute has changed and a title attribute is set.</p>
  22. </body>
  23. </html>
  24.  
  25. //javascript/8106

回复 "jQuery通过attr()方法同时设置多个属性值"

这儿你可以回复上面这条便签

captcha