返回值:jQueryafter(content|fn)
jQuery after() 方法概述
在每個(gè)匹配的元素之后插入內容。
參數
contentString, Element, jQueryV1.0
插入到每個(gè)目標后的內容
functionFunctionV1.4
函數必須返回一個(gè)html字符串。
示例
描述:
在所有段落之后插入一些HTML標記代碼。
HTML 代碼:
<p>I would like to say: </p>
jQuery 代碼:
$("p").after("<b>Hello</b>");
結果:
<p>I would like to say: </p><b>Hello</b>
描述:
在所有段落之后插入一個(gè)DOM元素。
HTML 代碼:
<b id="foo">Hello</b><p>I would like to say: </p>
jQuery 代碼:
$("p").after( $("#foo")[0] );
結果:
<p>I would like to say: </p><b id="foo">Hello</b>
描述:
在所有段落中后插入一個(gè)jQuery對象(類(lèi)似于一個(gè)DOM元素數組)。
HTML 代碼:
<b>Hello</b><p>I would like to say: </p>
jQuery 代碼:
$("p").after( $("b") );
結果:
<p>I would like to say: </p><b>Hello</b>