Anchor text Property - Change the text content of a link - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Anchor text Property - Change the text content of a link

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="http://www.example.com/test.htm#part2">Example link</a></p>

<button onclick="myFunction()">change the text content of the link above</button>

<script>
function myFunction() {/*from  w w  w . j av a  2 s  . c om*/
    document.getElementById("myAnchor").text = "Click me to open example link!";
}
</script>

</body>
</html>

Related Tutorials