ColumnGroup span Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:ColumnGroup


The span property sets or gets the span attribute of a <colgroup>.

Set the formMethod property with the following Values

Value Description
number Sets the number of columns a <colgroup> element should span

Return Value

A Number, representing the number of columns

Set the background color of the first two columns to red:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th, td {
    border:1px solid black;
</style>//ww w .  ja v  a 2 s  . c om

  <colgroup id="myColgroup"></colgroup>

<button onclick="myFunction()">set the background color of the first two columns</button>

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

function myFunction() {
    document.getElementById("myColgroup").span = "2";
    document.getElementById("myColgroup").style.backgroundColor = "blue";


Related Tutorials