x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
<script>
7
function alignCell() {
8
document.getElementById('td1').align = "right";
9
document.getElementById('td2').align = "right";
10
}
11
</script>
12
</head>
13
<body>
14
15
<table border="1">
16
<tr>
17
<th>第一个名称</th>
18
<th>下一个名称</th>
19
</tr>
20
<tr>
21
<td id="td1">Peter</td>
22
<td id="td2">Griffin</td>
23
</tr>
24
</table>
25
<br>
26
<input type="button" onclick="alignCell()" value="右对齐单元格" />
27
28
</body>
29
</html>