_$.prototype = {
each: function(fn){
for (var i = 0; i < this.elements.length; i++) {
fn.call(this, this.elements[i]); //第二个参数是fn函数的参数
}
},
setStyle: function(prop, val){
var that = this;
this.each(function(el){ //注意参数的设置
el.style[prop] = val;
});
return this;
}
}
window.$ = function(){
return new _$(arguments);
};
})();
window.onload = function(){
$("p", "p2").setStyle("color", "red");
}
script>
Hello world
Welcome.
Copyright © 2019- xixiwg.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务