Home  >  Article  >  Web Front-end  >  jquery plug-in learning (4)_jquery

jquery plug-in learning (4)_jquery

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

For the above example, we can call the jquery.fn.extend() method to create a jquery object method. The specific code is as follows》

Copy code The code is as follows:

jQuery.fn.extend({
test : function(){
return this.each(function(){
alert(this.nodeName);
})
}
});

The call is the same as above
Copy the code The code is as follows:

$(' body *').click(function(){
$(this).test().html(this.nodeName).hide(1000);
});

So far, we have introduced two methods of writing jquery plug-ins, jquery.extend() and jquery.fn.extend(). Have you learned it?
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