Get ColumnGroup Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:ColumnGroup


The ColumnGroup object represents an HTML <colgroup> element.

You can access a <colgroup> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th, td {
    border: 1px solid black;
</style>/*from   www .  j  a v  a2 s .c  o  m*/

  <colgroup id="myColgroup" span="2" style="background:red"></colgroup>

<button onclick="myFunction()">get the number of columns a COLGROUP element should span</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myColgroup").span;
    document.getElementById("demo").innerHTML = x;


Related Tutorials