1.转自:http://www.w3school.com.cn/jquery/manipulation_html.asp

设置所有 p 元素的内容:

 

 1 <html>
 2 <head>
 3 <script type="text/javascript" src="/jquery/jquery.js"></script>
 4 <script type="text/javascript">
 5 $(document).ready(function(){
 6   $(".btn1").click(function(){
 7     $("p").html("Hello <b>world!</b>");
 8   });
 9 });
10 </script>
11 </head>
12 <body>
13 <p>This is a paragraph.</p>
14 <p>This is another paragraph.</p>
15 <button class="btn1">改变 p 元素的内容</button>
16 </body>
17 </html>

 

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-09-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
相关资源
相似解决方案