$("p").append(function(n)是單個(gè)添加。
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
? $("button").click(function(){
? ? $("p").append(function(n){
? ? ? return "<br/>" + "<b>This p element has index " + n + "</b>";
? ? });
? });
});
</script>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraphAAA.</p>
<button>在每個(gè) p 元素的結(jié)尾添加內(nèi)容</button>
</body>
</html>
2018-10-06
因?yàn)槟阒挥幸粋€(gè)p標(biāo)簽,你每次只是在這唯一的p標(biāo)簽里添加了一個(gè)br標(biāo)簽,br標(biāo)簽個(gè)數(shù)在增加,p標(biāo)簽個(gè)數(shù)還是1
2018-03-14
before也不累加