본문 바로가기

Development/HTML

innerHTML


HTML Element Object

Definition and Usage

The innerHTML property sets or returns the inner HTML of an element.

Syntax

HTMLElementObject.innerHTML=text



 

Example

Change the text, URL, and target of a link:

<html>
<head>
<script type="text/javascript">
function changeLink()
{
document.getElementById('myAnchor').innerHTML="W3Schools";
document.getElementById('myAnchor').href="http://www.w3schools.com";
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>