Home > Web Front-end > HTML Tutorial > What is the usage of innerhtml?

What is the usage of innerhtml?

藏色散人
Release: 2020-09-08 09:11:49
Original
29798 people have browsed it

What is the usage of innerhtml?

The innerHTML attribute sets or returns the HTML between the start and end tags of the table row.

Syntax

tablerowObject.innerHTML=HTML
Copy after login

Example

The following example returns the inner HTML of a table row:

<html>
<head>
<script type="text/javascript">
function getInnerHTML()
  {
  alert(document.getElementById("tr1").innerHTML);
  }
</script>
</head>
<body>
<table border="1">
<tr id="tr1">
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr id="tr2">
<td>Peter</td>
<td>Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick="getInnerHTML()" 
value="Alert innerHTML of table row" />
</body>
</html>
Copy after login

Related recommendations: "HTML Tutorial" "javascript Tutorial"

This article is an introduction to the usage of innerhtml. I hope it will be helpful to friends in need!

The above is the detailed content of What is the usage of innerhtml?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template