zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jQuery中after的两种用法实例

jQuery实例 用法 两种 After
2023-06-13 09:15:02 时间
法一:
在每个p元素后插入内容:
复制代码代码如下:

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

法二:
复制代码代码如下:

 $("button").click(function(){
   $("p").after(function(n){
           return"<p>Thepelementabovehasindex"+n+"</p>";
   });
});

after中函数必须返回一个html字符串。