运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <p>Click the button to return the value of the colspan attribute of td with id "myTd".</p> <table> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td id="myTd" colspan="2">January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$100</td> </tr> </table> <br> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction(x) { var x = document.getElementById("myTd").colSpan; document.getElementById("demo").innerHTML = "The value of colspan is: " + x; } </script> </body> </html>