getElementById

B

bot-tak

Hi
it shouldn't be not so difficult
everytime, in each browser i see "nothing".
where is the element?

<html>
<head>
<script type="text/javascript">
alert(document.getElementById("cool"));
</script>
</head>
<body>
<p id="cool">this is content</p>
</body>
</html>

vassili
 
D

David Dorward

bot-tak said:
it shouldn't be not so difficult everytime, in each browser i see
"nothing". where is the element?
<html><head>
<script type="text/javascript">
alert(document.getElementById("cool"));
</script>
</head><body><p id="cool">this is content</p></body></html>

At the time the script it run, it doesn't exist.

window.onload = function(){
alert(document.getElementById("cool"));
}
 
E

Evertjan.

bot-tak wrote on 02 aug 2003 in comp.lang.javascript:
it shouldn't be not so difficult
everytime, in each browser i see "nothing".
where is the element?

<html>
<head>
<script type="text/javascript">
alert(document.getElementById("cool"));
</script>
</head>
<body>
<p id="cool">this is content</p>
</body>
</html>

try this, vassili:


<html>
<head>
</head>
<body>
<p id="cool">this is content</p>

<script type="text/javascript">
alert(document.getElementById("cool"));
alert(document.getElementById("cool").innerHTML);
</script>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top