HTML DOM TableHeader colSpan property
Examples
Change the number of columns spanned by a cell:
document.getElementById("myTh").colSpan="1";
try it"
Definition and Usage
colSpan property sets or returns the value of colspan attribute.
colspan attribute specifies the number of columns in a table cell can be spanned.
Tip: Use rowSpan property to set or return the value of rowspan attribute.
Browser Support
All major browsers support colSpan property.
grammar
Back colSpan properties:
tableheaderObject .colSpan
Setting colSpan properties:
tableheaderObject .colSpan=number
Property Value
值 | 描述 |
---|---|
number | 规定一个单元格可横跨的列数。 |
technical details
return value: | Number representing the number of columns in a table cell can be spanned. |
---|
More examples
Examples
Returns a specified number of columns in a table cell can be spanned:
var x = document.getElementById("myTh").colSpan;
document.getElementById("demo").innerHTML=x;
document.getElementById("demo").innerHTML=x;
x The output is:
2
try it"
related articles
HTML Reference Manual: HTML <TH> colspan attribute