Javascript examples for DOM HTML Element:ColumnGroup
The ColumnGroup object represents an HTML <colgroup> element.
You can access a <colgroup> element by using getElementById():
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>/*from www . j a v a2 s .c o m*/ </head> <body> <table> <colgroup id="myColgroup" span="2" style="background:red"></colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>001</td> <td>HTML</td> <td>$3</td> </tr> <tr> <td>001</td> <td>CSS</td> <td>$9</td> </tr> </table> <button onclick="myFunction()">get the number of columns a COLGROUP element should span</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myColgroup").span; document.getElementById("demo").innerHTML = x; } </script> </body> </html>