;(function() {
"user strict";
//默认参数
var size = {
var options = {
color: 'red'
};
}
//插件函数color
var color = {
//更新配置参数
var config: function(opts) {
if(!opts) return options;
for (var k in opts) {
options[k] = opts[k];
}
return this;
},
//监听事件
var listen: function(elem) {
var elems = document.getElementById('elem');
elems.addEventListener('click',function() {
this.style.color = options.color;
})
}
return this;
}
window.Color = color;
})()
//对象链式调用:
//Color.config({color: 'red'}).listen('#sz');
慕勒0069038
相关分类