jQuery Document Manipulation - after() Method
Example
Insert content after each p element:
$("button").click(function(){ $("p").after("<p>Hello world!</p>"); });
Definition and Usage
The after() method inserts specified content after the selected element.
Syntax
$("selector").after(content)
Parameter | Description |
---|---|
content | Required. Specifies the content to be inserted (can include HTML tags). |
Inserting Content with a Function
Use a function to insert specified content after the selected element.
Syntax
$("selector").after(function(index))
Parameter | Description |
---|---|
function(index) |
Required. Specifies the function to return the content to be inserted.
|