It is common to add text content to a table in practical applications. The following describes the specific implementation process. If you are interested, refer
The Code is as follows:
Table format processing. html
| Name |
Email |
Address |
| Jzy |
359@qq.com |
Chongqing |
| Jzy |
359@qq.com |
Chongqing |
Script
Document. getElementById ("submit"). onclick = function (){
// Alert ("success ");
// Obtain the input node
Var nameElement = document. getElementById ("iname ");
Var emailElement = document. getElementById ("iemail ");
Var addresssElement = document. getElementById ("iaddress ");
// Create a table Node
Var trNode = document. createElement ("tr ");
Var nameNode = document. createElement ("td ");
Var emailNode = document. createElement ("td ");
Var addressNode = document. createElement ("td ");
// Add the created node and text content to the table
Var borderElement = document. getElementById ("border ");
BorderElement. appendChild (trNode );
TrNode. appendChild (nameNode );
TrNode. appendChild (emailNode );
TrNode. appendChild (addressNode );
Var nametextNode = document. createTextNode (nameElement. value );
Var emailtextNode = document. createTextNode (emailElement. value );
Var addresstextNode = document. createTextNode (addresssElement. value );
NameNode. appendChild (nametextNode );
EmailNode. appendChild (emailtextNode );
AddressNode. appendChild (addresstextNode );
}
Script