[JavaScript] jQuery通过empty()方法删除元素及其所有子元素 →→→→→进入此内容的聊天室

来自 , 2021-03-23, 写在 JavaScript, 查看 113 次.
URL http://www.code666.cn/view/6a1a681b
  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").empty();
  10.   });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <div id="div1" style="height:100px;width:300px;border:1px solid black;background-color:yellow;">
  17.  
  18. This is some text in the div.
  19. <p>This is a paragraph in the div.</p>
  20. <p>This is another paragraph in the div.</p>
  21.  
  22. </div>
  23. <br>
  24. <button>Empty the div element</button>
  25.  
  26. </body>
  27. </html>
  28.  
  29. //javascript/8113

回复 "jQuery通过empty()方法删除元素及其所有子元素"

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

captcha