案例1:点击按钮禁用文本框
<input type="button" value="禁用文本框" id="btn" /> <input type="text" value="文本框" id="txt" /> <script> document.getElementById("btn").onclick = function () { document.getElementById("txt").disabled = true; }; </script>
案例2:点击按钮修改列表的背景颜色
<input type="button" value="变色" id="btn" /> <ul id="uu"> <li>王陆</li> <li>海云帆</li> <li>闻宝</li> <li>琉璃仙</li> <li>王舞</li> </ul> <script> document.getElementById("btn").onclick = function () { document.getElementById("uu").style.backgroundColor = "pink"; }; </script>