返回值:jQuery insertAfter(content)
概述
把所有匹配的元素插入到另一個、指定的元素元素集合的後面。
實際上,使用這個方法是顛倒了常規的$(A).after(B)的操作,即不是把B插入到A後面,而是把A插入到B後面。
在jQuery 1.3.2中,appendTo, prependTo, insertBefore, insertAfter, 和 replaceAll這個幾個方法成為一個破壞性操作,要選擇先前選中的元素,需要使用end()方法,參見 appendTo 方法的例二。
參數
content String V1.0
用於匹配元素的jQuery表達式
示例
描述:
把所有段落插入到一個元素之後。與 $("#foo").after("p")相同
HTML 程式碼:
<p>I would like to say: </p><div id="foo">Hello</div>
jQuery 程式碼:
$("p").insertAfter("#foo");
結果:
<div id="foo">Hello</div><p>I would like to say: </p>