fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <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>我的第一个HTML</td> <td>$53</td> </tr> <tr> <td>5869207</td> <td>我的第一个CSS</td> <td>$49</td> </tr> </table> <p>点击按钮设置表格中前两列的背景颜色为红色。</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ document.getElementById("myCol").span="2"; document.getElementById("myCol").style.backgroundColor="red"; } </script> </body> </html>
运行结果