HTML DOM getElementById() Method
Complete Document Object Reference
Definition and Usage
The getElementById() method returns a reference to the first object with the specified
ID.
Syntax
document.getElementById(id)
|
Example
<html>
<head>
<script type="text/javascript">
function getValue()
{
var x=document.getElementById("myHeader")
alert(x.innerHTML)
}
</script>
</head>
<body>
<h1 id="myHeader" onclick="getValue()">This is a header</h1>
<p>Click on the header to alert its value</p>
</body>
</html>
|
Try-It-Yourself Demos
Use getElementById()
Complete Document Object Reference
|
|
|