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

jquery plug-in learning (6)_jquery

WBOY
WBOYOriginal
2016-05-16 17:50:591242browse
Copy code The code is as follows:

;(function($){
$.extend($ .fn,{
color : function(options){
var options = $.extend({},$.fn.color.defaults,options);
return this.each(function(){
$(this).css("color",options.bcolor);
$(this).css("background",options.fcolor);
});
}// color==end
})
$.fn.color.defaults ={bcolor :"white",fcolor :"black"}

})(jQuery);

Copy code The code is as follows:

$.fn.color.defaults ={bcolor: "#c06",fcolor:"red"}//Write your own parameters and set the color
$('h1').color();
$('p').color({bcolor:" #fff"});//Repeatedly cover the north background color to white, and set the font by default

The above calls are either written outside or inside (). Have you learned it? ? That’s it for the detailed description of the parameters in this section. Welcome to my little learning world. I searched for plug-ins online and found them everywhere, but none of them really solved my problem. I studied them carefully and hope you can learn what you want here.
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