您的位置: 首页 > IT文章 > javascript类库 > jQuery中after的两种用法实例 jQuery中after的两种用法实例 分类: IT文章 • 2022-05-15 10:29:37 法一:在每个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字符串。