Javascript code _ javascript tips for adding text input box content to the table

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.