append
class="s1">s1
</span><span style="color: #000000;"></span></div><div>$<span style="color: #666600;">(</span><span style="color: #008800;">"p"</span><span style="color: #666600;">).</span><span style="color: #000000;">append</span><span style="color: #666600;">(</span><span style="color: #008800;">'<span class="s2">s2</span>'</span><span style="color: #666600;">);</span><span style="color: #000000;"></span></div><div><span style="color: #000088;">
结果是这样的:
class="s1">s1
class="s2">s2
after
class="s1">s1
</span><span style="color: #000000;"></span></div><div>$<span style="color: #666600;">(</span><span style="color: #008800;">"p"</span><span style="color: #666600;">).</span><span style="color: #000000;">after</span><span style="color: #666600;">(</span><span style="color: #008800;">'<span class="s2">s2</span>'</span><span style="color: #666600;">);</span><span style="color: #000000;"></span></div><div><span style="color: #000088;">
结果是这样的:
class="s1">s1
class="s2">s2
总结:
append/prepend 是在选择元素内部嵌入。
after/before 是在元素外面追加。