<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> tr td{ border: 1px solid blue; } </style> <script> window.onload = function (){ var oBtn1 = document.getElementById("btn1"); //按钮 var oTable = document.getElementById("bg1"); // table表格 var oTr = oTable.getElementsByTagName("tr"); // tr 行 var iPu = oTable.getElementsByTagName("input"); // table下的input oBtn1.onclick=function (){ iPu[0].checked=true; } //我想点击按钮之后,tr[0]的背景变成红色,这个效果实现了,但是我取消复选框中的小对勾之后,tr的背景,不能复原成原本的样子,要实现这个效果怎么写呀 } </script> </head> <body> <input id="btn1" type="button" value="全选" / > <table id="bg1"> <tr> <td> <input type="checkbox" / >Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident, ex, eius. Magnam, beatae quibusdam. Nemo adipisci veniam earum minus similique tempora dolorum, animi dolorem, esse, rerum molestias architecto! Culpa, excepturi! </td> </tr> <tr> <td> <input type="checkbox" / >Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident, ex, eius. Magnam, beatae quibusdam. Nemo adipisci veniam earum minus similique tempora dolorum, animi dolorem, esse, rerum molestias architecto! Culpa, excepturi! </td> </tr> <tr> <td> <input type="checkbox" / >Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident, ex, eius. Magnam, beatae quibusdam. Nemo adipisci veniam earum minus similique tempora dolorum, animi dolorem, esse, rerum molestias architecto! Culpa, excepturi! </td> </tr> </table> </body> </html>
如代码下方的疑问。
千秋此意
慕的地6079101
abc123456789def
学习js
相关分类