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

What is the usage of innerhtml?

藏色散人
藏色散人Original
2019-03-07 15:04:5529757browse

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

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>

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!

Statement:
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
Previous article:What is html5 technologyNext article:What is html5 technology