Monday, January 13, 2014

Example of document object getElementById().

<html>
<body>
<p>
<a id="Mahi" href="http://javascripttution.blogspot.com">My Blog</a>
</p>

<p>
Click the button to return the value of the href attribute of the link above.
</p>

<p id="Mayur"></p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var x = document.getElementById("Mahi").href;
document.getElementById("Mayur").innerHTML=x;
}
</script>
</body>
</html>

No comments:

Post a Comment