after() 方法在被选元素后插入指定的内容。
法一:
在每个p元素后插入内容:
$("button").click(function(){
$("p").after("<p>Hello world!</p>");
});
法二:
$("button").click(function(){
$("p").after(function(n){
return "<p>The p element above has index " + n + "</p>";
});
});
after中函数必须返回一个html字符串。
原帖地址:http://www.w3school.com.cn/jquery/manipulation_after.asp
本文介绍了 jQuery 中的 after() 方法,该方法用于在被选元素之后插入指定内容。通过两个实例展示了如何使用 after() 方法来添加 HTML 字符串,包括直接插入固定内容和通过索引动态生成内容。
1694

被折叠的 条评论
为什么被折叠?



