TableHeader colSpanProperty

TableHeader 对象参考手册TableHeader Object

Examples

Change the number of columns a cell spans:

document.getElementById("myTh").colSpan="1";

Try it Yourself »

Definition and Usage

The colSpan property sets or returns the value of the colspan attribute.

The colspan attribute specifies the number of columns a table cell should span.

Tip:UserowSpanproperty to set or return the value of the rowspan attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the colSpan property.


Syntax

Return the colSpan property:

tableheaderObject.colSpan

Set the colSpan property:

tableheaderObject.colSpan=number

Property Values

Value Description
number Specifies the number of columns a cell should span.

Technical Details

Return Value: A Number, representing the number of columns a table cell can span.


More Examples

Example

Return the number of columns a specified table cell can span:

var x = document.getElementById("myTh").colSpan;
document.getElementById("demo").innerHTML=x;

xThe output is:

2

Try it Yourself »


Related Articles

HTML Reference:HTML <th> colspan Attribute


TableHeader 对象参考手册TableHeader Object

Other Extensions