[JavaScript] jQuery通过append()方法html元素最后添加新的内容 →→→→→进入此内容的聊天室

来自 , 2021-03-31, 写在 JavaScript, 查看 122 次.
URL http://www.code666.cn/view/cfa45151
  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.   $("#btn1").click(function(){
  9.     $("p").append(" <b>Appended text</b>.");
  10.   });
  11.  
  12.   $("#btn2").click(function(){
  13.     $("ol").append("<li>Appended item</li>");
  14.   });
  15. });
  16. </script>
  17. </head>
  18.  
  19. <body>
  20. <p>This is a paragraph.</p>
  21. <p>This is another paragraph.</p>
  22. <ol>
  23. <li>List item 1</li>
  24. <li>List item 2</li>
  25. <li>List item 3</li>
  26. </ol>
  27. <button id="btn1">Append text</button>
  28. <button id="btn2">Append list items</button>
  29. </body>
  30. </html>
  31.  
  32. //javascript/8107

回复 "jQuery通过append()方法html元素最后添加新的内容"

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

captcha