What is innerHTML in javascript?

JavaScript

1 answer

Answer

1056382

2026-07-23 09:00

+ Follow

Java
Java

innerHTML is often used in Javasript to change the value already present in html tags. For eg The following code will change the text on button click

<html>

<head>

JavaScript
JavaScript

<script type="text/JavaScript">

function changeText()

{

document.getElementById("changeText").innerHTML = "I am fine thank you. How about you?"

}

</script>

</head>

<body>

<div id="changeText">

Hello! How are you?

</div>

<input type="button" value="Change Text" id="button_1" onclick="changeText()" />

</body>

</html>

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.