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
相关分类