当前位置:Gxlcms > JavaScript > jquery 插件学习(四)

jquery 插件学习(四)

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

针对上面的示例,我们可以调用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(),你学会了吗。

人气教程排行