站长资源网络编程
jquery 插件学习(四)
简介针对上面的示例,我们可以调用jquery.fn.extend()方法来创建jquery对象方法。具体代码如下》 复制代码 代码如下: jQuery.fn.extend({ test : function(){ return this.each(function(){ alert(this.nodeN
针对上面的示例,我们可以调用jquery.fn.extend()方法来创建jquery对象方法。具体代码如下》
复制代码 代码如下:
jQuery.fn.extend({
test : function(){
return this.each(function(){
alert(this.nodeName);
})
}
});
调用跟上面一样哦
复制代码 代码如下:
$('body *').click(function(){
$(this).test().html(this.nodeName).hide(1000);
});
到这里,已经介绍了写jquery插件的两种方法,jquery.extend() 和jquery.fn.extend(),你学会了吗。
复制代码 代码如下:
jQuery.fn.extend({
test : function(){
return this.each(function(){
alert(this.nodeName);
})
}
});
调用跟上面一样哦
复制代码 代码如下:
$('body *').click(function(){
$(this).test().html(this.nodeName).hide(1000);
});
到这里,已经介绍了写jquery插件的两种方法,jquery.extend() 和jquery.fn.extend(),你学会了吗。
上一篇:jquery 插件学习(五)
下一篇:jquery 插件学习(三)