(function () {
function jq(selector) {
const elements = document.querySelectorAll(selector)
function css(prop, value) {
elements.forEach(element=>{
element.style[prop] = value
})
return this
}
function text(value) {
elements.forEach(element=>{
element.innerText = value
})
return this
}
function prop(prop,value) {
elements.forEach(element=>{
element.setAttribute(prop,value)
})
return this
}
return {
css,
text,
prop
}
}
window.$ = jq
})()
IIFE立即执行函数避免第三库变量命名冲突
于 2023-11-23 19:31:23 首次发布