Column span Property - Return the number of columns a <col> element should span: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Column

Description

Column span Property - Return the number of columns a <col> element should span:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>//from  w  w  w .  jav a2s  . com
</head>
<body>

<table>
  <colgroup>
    <col id="myCol">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>001</td>
    <td>HTML</td>
    <td>$5</td>
  </tr>
  <tr>
    <td>002</td>
    <td>CSS</td>
    <td>$5</td>
  </tr>
</table>

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

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    var v = document.getElementById("myCol").span;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials