JavaScript operation DOM (Dynamic table Processing)

Source: Internet
Author: User

ClearForm() {document.getElementById ("Deptno"). value= "";          document.getElementById ("Dname"). value= ""; } window.onload=function () {document.getElementById ("addbtn"). AddEventListener ("click", Onloaddata,fal          SE); } functionOnloaddata() {var Deptno=document.getelementbyid ("Deptno"). Value;          var Dname=document.getelementbyid ("Dname"). Value;          AddRow (Deptno,dname);          ClearForm (); }//Delete:Find parent element, call its removechild ("Specify deleted element")functionRemoverow (Deptno) {var Deptrow=document.getelementbyid ("dept-" +deptno);          var Dept=document.getelementbyid ("Dept-body");          Dept.removechild (Deptrow); } functionAddRow(Deptno,dname)          {var trelt=document.createelement ("tr");          Trelt.setattribute ("id", "dept-" +deptno);//Set TR property var deptnotd=document.createelement ("TD");          var dnametd=document.createelement ("TD");                             var deltd=document.createelement ("TD"); var delbtn=document.createelement ("button");//Create Button Delbtn.appendchild (document.createTextNode ("delete"))                 ;//Append Text data delbtn.addeventlistener ("click", Function () {//Add Event Removerow (DEPTNO);                            },false);          Deltd.appendchild (DELBTN);          Deptnotd.appendchild (document.createTextNode (DEPTNO));          Dnametd.appendchild (document.createTextNode (dname));          Trelt.appendchild (DEPTNOTD);          Trelt.appendchild (DNAMETD);          Trelt.appendchild (DELTD);          document.getElementById ("Dept-body"). AppendChild (Trelt);  } </script> 

  

JavaScript operation DOM (Dynamic table Processing)

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.