Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery insertAfter() method

jQuery insertAfter() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Insert content after each

Insert an element after the element:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

Hello world!

"

)

.

insertAfter

(

"

p

"

)

;

}

)

;

Try it »


Definition and Usage

The insertAfter() method inserts HTML elements after the selected elements.

**Tip:** To insert HTML elements before the selected elements, use insertBefore() method.


Syntax

$(

content

).insertAfter(

selector

)

Parameters Description
content Required. Specifies the content to insert (must contain HTML tags).
 **注意:**如果 *content* 是已存在的元素,它将从它的当前位置被移除,并被插入在被选元素之后。 |

| selector | Required. Specifies where to insert the content. |


More examples

Inserting an existing element
How to use the insertAfter() method to insert an existing element after each selected element.


jQuery HTML/CSS methods jQuery HTML/CSS methods