jQuery API 返回首页目录 | jQuery API 中英文对照版
insertAfter(expr)
insertAfter(expr)

把所有匹配的元素插入到另一个、指定的元素元素集合的后面。

实际上,使用这个方法是颠倒了常规的$(A).after(B)的操作,即不是把B插入到A后面,而是把A插入到B后面。

返回值:jQuery

参数:

  • expr (String): 用于匹配元素的jQuery表达式
 

示例:

与 $("#foo").after("p")相同

$("p").insertAfter("#foo"); 

HTML 代码:

<p>I would like to say: </p><div   id="foo">Hello</div>

结果:

<div id="foo">Hello</div><p>I would like to   say: </p>
 
insertAfter( content )

Insert all of the matched elements after another, specified, set of elements. This operation is, essentially, the reverse of doing a regular $(A).after(B), in that instead of inserting B after A, you're inserting A after B.

Return value: jQuery
Parameters:

  • content (<Content>): Content to insert the selected element after.
 

Example:

Same as $("#foo").after("p")

 $("p").insertAfter("#foo");  
Before:
 <p>I would like to say: </p><div id="foo">Hello</div>  

Result:

 <div id="foo">Hello</div><p>I would like to say: </p>  
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog