ColSpan Property (td, Th) JavaScript - Dottoro Web Reference
Có thể bạn quan tâm
Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy. OK log in / join WordPress Theme & Editor Syntax Highlighter Blog log in / join WordPress Theme & Editor Syntax Highlighter Forum Blog You are here: Reference > JavaScript > client-side > HTML DOM > properties > colSpan (td, th) colSpan property (td, th) Browser support: Sets or retrieves how many columns wide a cell should be. If you want to change how many rows high the cell should be, use the rowSpan property.
Syntax:
object.colSpan; You can find the related objects in the Supported by objects section below. This property is read/write.HTML page for this property: colSpan |
Possible values:
Integer that sets or retrieves the number of columns to span. Default: this property has no default value.Example HTML code 1:
This example illustrates the use of the colSpan attribute:<tableborder="3px"id="myTable"><tr><tdcolspan="2">Apple</td></tr><tr><td>Pear</td><td>35.21</td></tr><tr><td>Peach</td><td>23.12</td></tr></table> | ||||
| ||||
Did you find this example helpful? yes no |
Example HTML code 2:
This example illustrates the use of the colSpan property:<head><scripttype="text/javascript">function ChangeColSpan () { var table = document.getElementById ("myTable"); // The first cell of the first row in the table var colToSpan = table.rows[0].cells[0].colSpan; colToSpan = (colToSpan == 2)? 1 : 2; table.rows[0].cells[0].colSpan = colToSpan; } </script></head><body><tableborder="3px"id="myTable"><tr><tdcolspan="2"style="background-color:red;">Apple</td></tr><tr><td>Pear</td><td>35.21</td></tr><tr><td>Peach</td><td>23.12</td></tr></table><buttononclick="ChangeColSpan ();">Change the colSpan property of the first cell!</button></body> | ||||
| ||||
Did you find this example helpful? yes no |
Supported by objects:
HTML elements:td, thRelated pages:
rowSpanExternal links:
colSpan (MSDN)colSpan (Safari Reference Library)colSpan (W3C) Share: Digg Del.icio.us Reddit Facebook Twitter Diigo User Contributed CommentsPost Content
WordPress Theme & Editor | Index Panel | Syntax Highlighter | Dottoro Link To Us | Terms of Use | Contact Us | Privacy Policy © 2024 Dottoro.com. All rights reserved. HTML CSS JavaScript AppendixTừ khóa » Html Colspan Javascript
-
HTML DOM TableData ColSpan Property - W3Schools
-
HTML Td Colspan Attribute - W3Schools
-
Set Colspan/rowspan For A Cell - Javascript - Stack Overflow
-
Javascript Reference - HTML DOM TableData ColSpan Property
-
Javascript DOM TableData Get And Set Column Span Property
-
Table Rowspan And Colspan In HTML Explained (With Examples) »
-
HTML Colspan Attribute - HTML Tutorials - W3resource
-
iaColSpan - Web APIs | MDN
-
HTML Colspan Attribute
-
The Table Element - HTML: HyperText Markup Language | MDN
-
HTML | DOM TableData ColSpan Property - GeeksforGeeks
-
HTML DOM TableHeader ColSpan Property - GeeksforGeeks
-
HTML Th Colspan Attribute - W3Schools
-
How To Change Colspan=“6” To Colspan =“4” In TD Using JQuery ...