innerText 和 innerHTML


give value

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled document</title>


<script>
	
	
	function inner()
	{
		var di1 = document.getElementById('div1');
		var di2 = document.getElementById('div2');
		var di3 = document.getElementById('div3');
		
		di1.innerHTML = "<font color='red'> Hello </font>";
		di2.innerText = "<font color='red'> Hello </font>"
	}
	
	</script>
</head>

<body>
<div id="div1" style="border: solid 1px;color: black"></div>
<hr>
<div id="div2" style="border: solid 1px;color: black"></div>


<input  type="button" onClick="inner()">

</body>
</html>

Value:

                var di11 = document.innerHTML;
		
		var di12 = document.innerText;
		


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325931603&siteId=291194637