当前位置:Gxlcms > JavaScript > jQuery中after的两种用法实例_jquery

jQuery中after的两种用法实例_jquery

时间:2021-07-01 10:21:17 帮助过:5人阅读

法一:
在每个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字符串。

人气教程排行