<div id="dome">sdfsd</div> <div id="test">gfdg</div>
function $(id) { return document.getElementById(id); } $("dome").style.backgroundColor='red'; $("test").style.backgroundColor='pink';
function $(id) { return document.getElementById(id); }
此方法就是封装了一个$()函数,可以方便获取dom中的id。