<br />Related articles: innerHTML HTML DOM insertRow() Method Definition and Usage Definition and Usage The insertRow() method is used to insert a new row at a specified position in a table. The insertRow() method can be used to insert a new row at a specified position in the table. Syntax tableObject.insertRow(index) //Index, add a new row -------------------------------------------------------------------------------- Example <html> <head> <script type="text/javascript"> function insRow() { document.getElementById('myTable').insertRow(0) //Find the control in the document } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>Row1 cell1</td> <td>Row1 cell2</td> </tr> <tr> <td>Row2 cell1</td> <td>Row2 cell2</td> </tr> </table> <form>//Place controls in the form <input type="button" onclick="insRow()" value="Insert new row before the first row">//value is the content to be displayed on the control </form> </body> </html> In the js method, you can directly use the id.innerHtml of the paired tags to assign the tag content without declaring variables in the js method. innerHTML is an attribute of the html tag. Most of the tags that appear in pairs have this attribute. //The tag attribute is the characters between the start tag and the end tag, not including the tag itself. For example <p id="pp">aaaaaaaaaaa<span id="ss">bbbbbbbb</span> </p> Here the p tag and span tag are nested together, so the content of pp.innerHTML is aaaaaaaaaaa<span id="ss">bbbbbbbb</span> The content of ss.innerHTML is bbbbbbbb ========================= A similar property is outerHTML Then the content of pp.outerHTML is <p id="pp">aaaaaaaaaaa<span id="ss">bbbbbbbb</span> </p> The content of ss.outerHTML is <span id="ss">bbbbbbbb</span> |
<<: How to safely shut down MySQL
>>: Multi-service image packaging operation of Dockerfile under supervisor
<base target=_blank> changes the target fram...
Table of contents Vue life cycle introduction and...
Table of contents 1. DHCP Service (Dynamic Host C...
Table of contents 1. Overview 2. Download the Ngi...
This article uses examples to explain the princip...
Table of contents this Method In the object Hidde...
1. Introduction resolv.conf is the configuration ...
B-tree is a common data structure. Along with him...
1. Use floating method Effect picture: The code i...
Yum (full name Yellow dog Updater, Modified) is a...
This article example shares the specific code of ...
Table of contents What is the rest operator? How ...
<br />This is a series of tutorials provided...
When it comes to styling our web pages, we have t...
Writing a Dockerfile Taking the directory automat...