[JavaScript] jQuery通过CSS()方法获得元素的指定样式 →→→→→进入此内容的聊天室

来自 , 2021-05-01, 写在 JavaScript, 查看 145 次.
URL http://www.code666.cn/view/45d6637b
  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.     alert("Background color = " + $("p").css("background-color"));
  10.   });
  11. });
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. <h2>This is a heading</h2>
  17. <p style="background-color:#ff0000">This is a paragraph.</p>
  18. <p style="background-color:#00ff00">This is a paragraph.</p>
  19. <p style="background-color:#0000ff">This is a paragraph.</p>
  20. <button>Return background-color of p</button>
  21. </body>
  22. </html>
  23.  
  24. //javascript/8119

回复 "jQuery通过CSS()方法获得元素的指定样式"

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

captcha