Javascript can't find element by id?

Posted by Bluemagica on Stack Overflow See other posts from Stack Overflow or by Bluemagica
Published on 2010-12-21T10:52:12Z Indexed on 2010/12/21 10:53 UTC
Read the original article Hit count: 232

Filed under:
|
<html>
<head>
    <title>Test javascript</title>

    <script type="text/javascript">
        var e = document.getElementById("db_info");
        e.innerHTML='Found you';
    </script>
</head>
<body>
    <div id="content">
        <div id="tables">

        </div>        
        <div id="db_info">
        </div>
    </div>
</body>
</html>

If I use alert(e); it turns up null.... and obviously I don't get any "found you" on screen. What am I doing wrong?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about getelementbyid