Latest web development tutorials

jQuery after () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

Insert content after each <p> element:

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

try it"

Definition and Usage

after () method to insert the specified content in the selected elements.

Tip: To insert content before the selected element, use before () method.


grammar

$(selector).after(content,function(index))

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

可能的值:

  • HTML 元素
  • jQuery 对象
  • DOM 元素
function(index) 规定返回待插入内容的函数。
  • index- 返回集合中元素的 index 位置。


Examples

More examples

after () - Create content via HTML, jQuery and DOM
() Method to insert content through after.

Use function Inserts
How to use the function after being selected element insertions.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods