<html>
<head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ //alert($("p").html());//返回值:連帶標(biāo)簽全部返回,但只限于第一個(gè)匹配元素的innerHtml $("p").html("Hello <b>world!</b>");//設(shè)置innerHtml alert($("p").text())//返回所有text值,標(biāo)簽忽略 alert($("p").html()); })}); </script> </head> <body> <p value="aaaaa">This is<br> a paragraph.</p> <p value="bbbbb">This is another paragraph.</p> <button class="btn1">改變 p 元素的內(nèi)容</button> </body> </html> |
|