Home > Web Front-end > JS Tutorial > JS method to control the alignment of specified cell content in a table_javascript skills

JS method to control the alignment of specified cell content in a table_javascript skills

WBOY
Release: 2016-05-16 16:07:05
Original
1227 people have browsed it

The example in this article describes the JS method of controlling the content alignment of specified cells in a table. Share it with everyone for your reference. The details are as follows:

The following code controls the content of the table cell to be aligned to the right

<!DOCTYPE html>
<html>
<head>
<script>
function alignCell()
{
document.getElementById('td1').align="right";
}
</script>
</head>
<body>
<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td id="td1">Peter</td>
<td id="td2">Griffin</td>
</tr>
</table>
<br>
<input type="button" onclick="alignCell()" value="Align cell" />
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template