Using get element by id
By krates | January 17, 2008
Get element by id is a function which will return the the content inside a element for example
Example
<html>
<head>
<script type=”text/javascript” >
function gebid(){
var xyz=document.getElementById(“text”);
alert(xyz.innerHTML);
}
</script>
</head>
<body>
<h1 id=”text” onclick=”gebid()”>You will see this same text when you will click here</h1>
</body>
</html>
Thanks
krates
Topics: Javascript | 4 Comments »
Related Links:

February 21st, 2008 at 9:48 am
Nope, you won’t, it needs to be alert(xyz.innerHTML);
-Tom
February 21st, 2008 at 2:24 pm
Thanks for telling it was a silly mistake by me.
June 16th, 2008 at 6:46 am
I have this code written down as a JS code but am prgramming in XUL not html.
June 16th, 2008 at 6:48 am
What needs to be chnaged