Understanding innerHTML

Understanding innerHTML
<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

Recommend

base target="" controls the link's target open frame

<base target=_blank> changes the target fram...

Introduction to Vue life cycle and detailed explanation of hook functions

Table of contents Vue life cycle introduction and...

A very detailed explanation of the Linux DHCP service

Table of contents 1. DHCP Service (Dynamic Host C...

Teach you how to quickly install Nginx in CentOS7

Table of contents 1. Overview 2. Download the Ngi...

MySql knowledge points: transaction, index, lock principle and usage analysis

This article uses examples to explain the princip...

JavaScript basics of this pointing

Table of contents this Method In the object Hidde...

A brief analysis of Linux resolv.conf

1. Introduction resolv.conf is the configuration ...

Introduction to the properties of B-Tree

B-tree is a common data structure. Along with him...

Install and build a server environment of PHP+Apache+MySQL on CentOS

Yum (full name Yellow dog Updater, Modified) is a...

Vue implements tree table

This article example shares the specific code of ...

HTML table markup tutorial (1): Creating a table

<br />This is a series of tutorials provided...

Will CSS3 really replace SCSS?

When it comes to styling our web pages, we have t...

Docker uses dockerfile to start node.js application

Writing a Dockerfile Taking the directory automat...