English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
the after() method to insert specified content after the selected element.
To insert content before the selected element, please usebefore()Method.
Inserting content:
$(selector).after(content)
Inserting content using a function:
$(selector).after(function(index))
Inserting content after each paragraph:
$("button").click(function(){ $("p").after("<p>Hello world</p>"); });Test See‹/›
Inserting content using a function:
$("button").click(function(){ $("p").after(function(i){ return "<p>This p element's index: " + i + ".</p>"; }); });Test See‹/›
Parameter | Description |
---|---|
content | Specify the content to be inserted after each selected element (can include HTML tags) Possible values:
|
function(index) | Specify a function that returns the content to be inserted
|