JS实现点击按钮自动增加一个单元格的方法

本文实例讲述了JS实现点击按钮自动增加一个单元格的方法。分享给大家供大家参考。具体分析如下:

这是一个网页在线自助生成表格的特效代码。
核心功能代码是JS实现,点击网页中的添加按钮,网页中自动增加一个单元格


<HTML>

<HEAD>

<TITLE>js动态生成表格</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='动态生成表格' onclick=creates()><br>

</body>

</HTML>

希望本文所述对大家的javascript程序设计有所帮助。