Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?73c27e26f610eb3c9f3feb0c75b03925"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </head> <body> <p>Click the button to return the value of the rowspan attribute of th with id "myTh".</p> <table> <tr> <th id="myTh" rowspan="2">Month</th> <th>Savings</th> </tr> <tr> <td>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("myTh").rowSpan; document.getElementById("demo").innerHTML = "The value of rowspan is: " + x; } </script> </body> </html>
Result: