Latest web development tutorials

HTML DOM innerHTML property

Elements Object Reference Element object


Definition and Usage

innerHTML property sets or returns the HTML start and end tags between table rows.

grammar

HTMLElementObject.innerHTML=text


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support innerHTML property


Examples

Examples

Change the text, URL, and the link destination:

<html>
<head>
<script>
function changeLink()
{
document.getElementById('myAnchor').innerHTML="W3Cschool";
document.getElementById('myAnchor').href="http://www.w3cschool.cc";
document.getElementById('myAnchor').target="_blank";
}
</script>
</head>
<body>

<a id="myAnchor" href="http://www.microsoft.com">Microsoft</a>
<input type="button" onclick="changeLink()" value="Change link">

</body>
</html>

try it"


Elements Object Reference Element object