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

What is the use of the enctype field when uploading files?

The enctype attribute of the FORM element specifie...

Layui implements sample code for multi-condition query

I recently made a file system and found that ther...

Implementation of Node connection to MySQL query transaction processing

Table of contents Enter the topic mysql add, dele...

MySQL 5.7.21 installation and configuration tutorial under Window10

This article records the installation and configu...

Table paging function implemented by Vue2.0+ElementUI+PageHelper

Preface I have been working on some front-end pro...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

IDEA graphic tutorial on configuring Tomcat server and publishing web projects

1. After creating the web project, you now need t...

Use of Vue filters and custom instructions

Table of contents Filters 01.What is 02. How to d...

MySQL 5.7.21 Installer Installation Graphic Tutorial under Windows 10

Install MySQL and keep a note. I don’t know if it...

Vue custom component implements two-way binding

Scenario: The interaction methods between parent ...

What does mysql database do

MySQL is a relational database management system ...

MySQL slave library Seconds_Behind_Master delay summary

Table of contents MySQL slave library Seconds_Beh...

A brief discussion on common operations of MySQL in cmd and python

Environment configuration 1: Install MySQL and ad...