There are currently two popular methods to dynamically operate client controls,
One is innerhtml. This method is understandable and can accomplish tasks, but I do not recommend this method,
Second, upload Doc ument. createelement (),
For example, there is such a tag in the Web: <Div id = "testdiv"> </div>
We can create a table in Div as follows:
VaR table = invalid argument Doc ument. createelement ("table ");
VaR row1 = invalid argument Doc ument. createelement ("TR ");
VaR cell1 = too many Doc ument. createelement ("TD ");
VaR cell1_value = too many Doc ument. createtextnode ("A test table! ");
Cell1.appendchild (cell1_value );
Row1.appendchild (cell1 );
Table. appendchild (row1 );
Invalid Response Doc ument. getelementbyid ("testdiv"). appendchild (table );
Similarly, when creating other controls, you only need to pay attention to the tags you want to create. For example, when you want to create a select, You need to append option.
When modifying, you must first wnidow.doc ument. getelementbyid and then search for the node to be modified,
1. childnodes [X], locate by serial number
2. nextsibling: Next node of the current node
3. previussibling the previous node of the current node
4. firstchild
5. lastchild
In fact, you can use the following methods to operate some controls on the server, because the controls are sent from the server to the client, the display on the client is based on the most basic html.