This article describes the method of JS to automatically add a cell by clicking a button. Share it for your reference. The specific analysis is as follows:
This is a special effect code for a self-service webpage to generate the form online.
The core function code is implemented by JS. Click the Add button in the web page and automatically add a cell to the web page.
The code copy is as follows:
<HTML>
<HEAD>
<TITLE>js dynamically generate table</TITLE>
<META content="text/html; charset=hz-gb-2312" http-equiv=Content-Type>
</HEAD>
<script>
function creates(){
newiframes=document.createElement("TABLE")
newiframes.id="t1"
newiframes.width="100"
newiframes.border="1"
newiframes.height="100"
newiframes.align="left"
newiframes.style.background="blue"
newiframes.insertRow()
newiframes.rows[0].insertCell()
document.body.insertBefore(newiframes)
}
</script>
<body>
<input type=button value='Dynamic generated table' onclick=creates()><br>
</body>
</HTML>
I hope this article will be helpful to everyone's JavaScript programming.