HTML DOM innerHTML property
Definition and Usage
innerHTML property sets or returns the HTML start and end tags between table rows.
grammar
HTMLElementObject.innerHTML=text
Browser Support
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>
<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"