var $ = function (selector) {
return new $.prototype.init(selector);
};
$.prototype = {
init: function (selector) {
this.el = document.querySelector(selector);
console.log(this)
return this;
},
on: function (event, fn) {
if (window.addEventListener) {
this.el.addEventListener(event, fn, false);
} else if (window.attachEvent) {
this.el.attachEvent(on + event, fn);
}
return this;
},
attr: function (event, val) {
if (!val) {
return this.el.getAttribute(event);
} else {
this.el.setAttribute(event, val);
return this;
}
}
}
$.prototype.init.prototype = $.prototype;
欧罗巴皇
hahhhha
uhelper_net
随时随地看视频慕课网APP
相关分类