<div id='container' class='container'>盒子</div>
<button onClick="f()" >test按钮</button>
class JQuery {
constructor(name){
this.doc = document.getElementById(name);
}
html(html){
this.doc.innerHTML = html;
return this;
}
color(color){
this.doc.style.backgroundColor = color;
return this
}
}
window.$ = function (name) {
return new JQuery(name);
}
function f(){
$('container').html('改变了').color('#ade')
}
效果: