Home  >  Article  >  Web Front-end  >  jquery 插件学习(四)_jquery

jquery 插件学习(四)_jquery

WBOY
WBOYOriginal
2016-05-16 17:51:031044browse

针对上面的示例,我们可以调用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(),你学会了吗。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn