<div class="codetitle"> <span><a style="CURSOR: pointer" data="51765" class="copybut" id="copybut51765" onclick="doCopy('code51765')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code51765"> <br><span style="FONT-SIZE: 14px"> <br> <br> <br><title>表格处理.html</title> <br><br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <br><meta http-equiv="description" content="this is my page"> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <br><br><!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <br><br> <br><br> <br><form id="form1"> <br><input type="text" id="iname"> <br><input type="text" id="iemail"> <br><input type="text" id="iaddress"> <br><input type="button" value="提交" id="submit"> <br> </form> <br><br><hr> <br><br><table border="1" id="border"> <br><tr> <br><td id="name">姓名</td> <br><td id="email">邮箱</td> <br><td id="address">地址</td> <br> </tr> <br><tr> <br><td id="name">jzy</td> <br><td id="email">359@qq.com</td> <br><td id="address">重庆</td> <br> </tr> <br><tr> <br><td id="name">jzy</td> <br><td id="email">359@qq.com</td> <br><td id="address">重庆</td> <br> </tr> <br> </table> <br> <br><script> <BR>document.getElementById("submit").onclick=function(){ <BR>//alert("success"); <BR>//获取输入节点 <BR>var nameElement=document.getElementById("iname"); <BR>var emailElement=document.getElementById("iemail"); <BR>var addresssElement=document.getElementById("iaddress"); <br><br>//创建表格节点 <BR>var trNode=document.createElement("tr"); <BR>var nameNode=document.createElement("td"); <BR>var emailNode=document.createElement("td"); <BR>var addressNode=document.createElement("td"); <br><br>//向表格中添加创建的节点及文本内容 <BR>var borderElement=document.getElementById("border"); <BR>borderElement.appendChild(trNode); <BR>trNode.appendChild(nameNode); <BR>trNode.appendChild(emailNode); <BR>trNode.appendChild(addressNode); <BR>var nametextNode=document.createTextNode(nameElement.value); <BR>var emailtextNode=document.createTextNode(emailElement.value); <BR>var addresstextNode=document.createTextNode(addresssElement.value); <BR>nameNode.appendChild(nametextNode); <BR>emailNode.appendChild(emailtextNode); <BR>addressNode.appendChild(addresstextNode); <br><br>} <BR></script> <br> <br></span> <br> </div>