Home  >  Article  >  Web Front-end  >  JS method to control vertical alignment of table cells_javascript skills

JS method to control vertical alignment of table cells_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:07:071258browse

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

The following code controls the vertical alignment of the specified cells at the bottom

<!DOCTYPE html>
<html>
<head>
<script>
function valignCell()
{
var x=document.getElementById('myTable').rows[0].cells;
x[0].vAlign="bottom";
}
</script>
</head>
<body>
<table id="myTable" border="1" height="70%">
<tr>
<td>First cell</td>
<td>Second cell</td>
</tr>
<tr>
<td>Third cell</td>
<td>Fourth cell</td>
</tr>
</table>
<form>
<input type="button" onclick="valignCell()"
value="Vertical align cell content">
</form>
</body>
</html>

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

Statement:
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