td/th chProperty

td/th 对象参考手册td/th Object

Definition and Usage

The ch property sets or returns the alignment character of a cell.

The alignment of all cell contents in the same column depends on this character.

Syntax

Set the ch property:

tdObject.ch="text"

or

thObject.ch="text"

Return the ch property:

tdObject.ch

or

thObject.ch

TipThe property has no default value.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the ch property. However, no major browser implements the functionality of this property.


Example

Example

Align the "Savings" column with the "." character:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function displayResult(){
    var c=document.getElementById("myCol");
alert("The alignment character of the second column is: " + c.ch);
}
</script>
</head>
<body>

<table border="1">
    <colgroup>
        <col>
        <col id="myCol" align="char" char=".">
    </colgroup>
    <tr>
<th>Month</th>
<th>Savings</th>
    </tr>
    <tr>
        <td>January</td>
        <td>$100.00</td>
    </tr>
    <tr>
        <td>February</td>
        <td>$10.00</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">Get character alignment</button>
<p><b>Note:</b> Not all major browsers support the char property.</p>

</body>
</html>

Try it Yourself »


td/th 对象参考手册td/th Object Other Extensions