0
이 플러그인에서 jQuery로 배경색을 변경하고 싶습니다. 기본 배경색은 빨간색이지만, 매개 변수를 무시하려고 할 때 작동하지 않습니다. 여기 배경색을 녹색으로 설정하려고합니다. 하지만 여전히 빨간색, 작동하지 여기jQuery 플러그인 대체 매개 변수
플러그인 파일 여기
(function($){
if(!$.fn){
$.fn = new Object();
};
$.fn.myBgcolor = function(el, options){
// To avoid scope issues, use 'base' instead of 'this'
// to reference this class from internal events and functions.
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
// Add a reverse reference to the DOM object
base.$el.data("fn.myBgcolor", base);
base.init = function(){
base.options = $.extend({},$.fn.myBgcolor.defaultOptions, options);
// Put your initialization code here
};
// Sample Function, Uncomment to use
base.BGcolor = function(paramaters){
base.css("background-color", base.options.bgColor);
};
// Run initializer
base.init();
base.BGcolor();
};
$.fn.myBgcolor.defaultOptions = {
bgColor: "red"
};
$.fn.fn_myBgcolor = function(options){
return this.each(function(){
(new $.fn.myBgcolor(this, options));
});
};
// This function breaks the chain, but returns
// the fn.myBgcolor if it has been attached to the object.
$.fn.getfn_myBgcolor = function(){
this.data("fn.myBgcolor");
};
})(jQuery);
에 대한 코드는 HTML 파일에 대한 코드가 있습니다 난 당신이에 의해 달성하려고하는 것을 확실하지 않다
<p class="ele">dfdfg</p>
$(".ele").myBgcolor({
bgColor: "green"
});