ColSpan Property (td, Th) JavaScript - Dottoro Web Reference

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>
Copy Code Print Preview Syntax Highlighter
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>
Copy Code Print Preview Syntax Highlighter
Did you find this example helpful? yes no

Supported by objects:

HTML elements:td, th

Related pages:

rowSpan

External links:

colSpan (MSDN)colSpan (Safari Reference Library)colSpan (W3C) Share: Digg Del.icio.us Reddit Facebook Twitter Diigo User Contributed Comments

Post Content

Post 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 Appendix

Từ khóa » Html Colspan Javascript