Home  >  Article  >  Web Front-end  >  js method to dynamically modify table row colspan column span_javascript skills

js method to dynamically modify table row colspan column span_javascript skills

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

The example in this article describes the method of dynamically modifying the colspan column span of table rows in js. Share it with everyone for your reference. The details are as follows:

<!DOCTYPE html>
<html>
<head>
<script>
function setColSpan()
{
var x=document.getElementById('myTable').rows[0].cells;
x[0].colSpan="2";
x[1].colSpan="6";
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td colspan="4">cell 1</td>
<td colspan="4">cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
<td>cell 5</td>
<td>cell 6</td>
<td>cell 7</td>
<td>cell 8</td>
<td>cell 9</td>
<td>cell 10</td>
</tr>
</table>
<form>
<input type="button" onclick="setColSpan()" 
value="Change colspan">
</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