切换主题
字数
70 字
阅读时间
1 分钟
js
class jQuery {
constructor(selector) {
const result = document.querySelectorAll(selector)
const length = result.length;
for (let i = 0; i < length; i++) {
this[i] = result[i]
}
this.length = length;
this.selector = selector;
}
get(index) {
return this[index]
}
each(fn) {
for (let i = 0; i < this.length; i++) {
const eleme = this[i]
fn(eleme)
}
}
on(type,fn,index2){
this.index2= index2;
this[index2].addEventListener(type,fn)
}
}
贡献者
sunchengzhi