1.三个按钮,点击任意按钮所有的按钮本景色改变
<body> <input type="button" value="按钮1"> <input type="button" value="按钮2"> <input type="button" value="按钮3"> <script> var buttons = document.getElementsByTagName("input") for(var i = 0; i< buttons.length; i++){ buttons[i].onclick = function(){ for(var j = 0; j < buttons.length; j++){ buttons[j].style.background = 'yellow'; } } } </script>