Simple Javascript Won't work

Posted by webzide on Stack Overflow See other posts from Stack Overflow or by webzide
Published on 2010-04-26T21:45:41Z Indexed on 2010/04/26 21:53 UTC
Read the original article Hit count: 258

Filed under:
|

Dear Experts, I was testing some code and I became very frustrated as I couldn't even get an simple DOM alert box to work

Anyway here's the code

<!DOCTYPE HTML PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/tdt/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
<!--
    var x=document.getElementById("myHeader");
    alert(x.innerHTML);
//-->
</script>
</head>
<body>

<h1 id="myHeader">Click me!</h1>

</body>
</html> 

I don't know what I did wrong but I just don't see the alert box.

I use FF btw.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html