在每个p元素后插入内容:
复制代码 代码如下:
$("button").click(function(){
$("p").after("
Hello world!
");});
法二:
复制代码 代码如下:
$("button").click(function(){
$("p").after(function(n){
return "
The p element above has index " + n + "
";});
});
after中函数必须返回一个html字符串。

Hello world!
");The p element above has index " + n + "
";