For the above example, we can call the jquery.fn.extend() method to create a jquery object method. The specific code is as follows》
jQuery.fn.extend({
test : function(){
return this.each(function(){
alert(this.nodeName);
})
}
});
The call is the same as above
$(' 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