js【封装】$id函数--方便获取dom中的id
<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。
给心灵一个纯净空间,让思想,情感,飞扬!