Latest web development tutorials

jQuery insertAfter () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

Insert a <span> element after each <p> element:

$("button").click(function(){
$("<span>Hello world!</span>").insertAfter("p");
});

try it"

Definition and Usage

insertAfter () method after the selected element into an HTML element.

Tip: If you need before being selected element into an HTML element, use the insertBefore () method.


grammar

$(content).insertAfter(selector)

参数 描述
content 必需。规定要插入的内容(必须包含 HTML 标签)。

注意:如果content是已存在的元素,它将从它的当前位置被移除,并被插入在被选元素之后。
selector 必需。规定在何处插入内容。


Examples

More examples

Insert an existing element
How insertAfter () method after each of the selected element into an existing element.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods