JavaScript DOM操作案例点击按钮修改ul背景颜色
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <input type="button" value="修改颜色" id="bt"/> <ul id="u"> <li>涂山红红</li> <li>涂山雅雅</li> <li>涂山蓉蓉</li> <li>涂山苏苏</li> <li>涂山小姑爷</li> </ul> <script> document.getElementById("bt").onclick = function () { document.getElementById("u").style.backgroundColor = "pink"; }; </script> </body> </html>