[JavaScript] jQuery通过addClass()方法给元素添加多个class →→→→→进入此内容的聊天室

来自 , 2020-11-13, 写在 JavaScript, 查看 123 次.
URL http://www.code666.cn/view/68dd09b9
  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.     $("#div1").addClass("important blue");
  10.   });
  11. });
  12. </script>
  13. <style type="text/css">
  14. .important
  15. {
  16. font-weight:bold;
  17. font-size:xx-large;
  18. }
  19. .blue
  20. {
  21. color:blue;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26.  
  27. <div id="div1">This is some text.</div>
  28. <div id="div2">This is some text.</div>
  29. <br>
  30. <button>Add classes to first div element</button>
  31.  
  32. </body>
  33. </html>
  34.  
  35. //javascript/8116

回复 "jQuery通过addClass()方法给元素添加多个class"

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

captcha