jQuery中after的两种用法实例
更新时间:2013年07月03日 15:45:02 作者:
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字符串。
在每个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字符串。
相关文章
AMD异步模块定义介绍和Require.js中使用jQuery及jQuery插件的方法
这篇文章主要介绍了AMD异步模块定义介绍和Require.js中使用jQuery及jQuery插件的方法,需要的朋友可以参考下2014-06-06


最新评论