运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> table { width: 100%; } table, th, td { border: 1px solid black; } </style> </head> <body> <p>Click the button to change the value of the headers attribute of td with id "myTd".</p> <table> <tr> <th id="name">Name</th> <th id="email">Email</th> <th id="phone">Phone</th> <th id="addr">Address</th> </tr> <tr> <td id="myTd" headers="name">John Doe</td> <td headers="email">someone@example.com</td> <td headers="phone">+45342323</td> <td headers="addr">Rosevn 56,4300 Sandnes,Norway</td> </tr> </table> <br> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myTd").headers = "newValue"; document.getElementById("demo").innerHTML = "The value of the headers attribute was changed from 'name' to 'newValue'."; } </script> </body> </html>