运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往空间
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <table> <colgroup> <col id="myCol"> <col style="background-color:yellow"> </colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>3476896</td> <td>My first HTML</td> <td>$53</td> </tr> <tr> <td>5869207</td> <td>My first CSS</td> <td>$49</td> </tr> </table> <p>Click the button to set the background color of the first two columns to red.</p> <p id="demo"></p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myCol").span = "2"; document.getElementById("myCol").style.backgroundColor = "red"; } </script> </body> </html>