Home  >  Article  >  Web Front-end  >  Add the text input box content to the js code in the table_javascript skills

Add the text input box content to the js code in the table_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:25:251127browse
复制代码 代码如下:




表格处理.html




































姓名 邮箱 地址
jzy 359@qq.com 重庆
jzy 359@qq.com 重庆


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


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