[JavaScript] jquery通过remove()方法删除指定元素下指定class的子元素 →→→→→进入此内容的聊天室

来自 , 2020-12-10, 写在 JavaScript, 查看 141 次.
URL http://www.code666.cn/view/51f15efd
  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.     $("p").remove(".italic");
  10.   });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <p>This is a paragraph in the div.</p>
  17. <p class="italic"><i>This is another paragraph in the div.</i></p>
  18. <p class="italic"><i>This is another paragraph in the div.</i></p>
  19. <button>Remove all p elements with class="italic"</button>
  20.  
  21. </body>
  22. </html>
  23.  
  24. //javascript/8114

回复 "jquery通过remove()方法删除指定元素下指定class的子元素"

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

captcha