Change the number of rows a table cell should span:
document.getElementById("myTd").rowSpan = "1";
Click the button to change the value of the rowspan attribute, from 2 to 1, of td with id=myTd
.
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>// w ww .j ava2 s. c o m </head> <body> <table border="1"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td id="myTd" rowspan="2">January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$100</td> </tr> </table> <br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myTd").rowSpan = "1"; } </script> </body> </html>
The rowSpan property sets or gets the value of the rowspan attribute.
The rowspan attribute specifies the number of rows a table cell should span.
The rowSpan property returns a Number representing the number of rows a table cell should span.