Call Onclick of Div Using javacsript
<p>I want to alert something in the onclick event of a div .</p>

<p>This is my code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
document.getElementById('new_div').click(function() {
    alert(1);

});

&lt;/script&gt;

&lt;div id="new_div" style="border:1px solid;"&gt;
Clicked Me......
&lt;/div&gt;
</code></pre>

<p>But when loading the page it displays an error:</p>

<pre><code>document.getElementById("new_div") is null
</code></pre>

<p>What is the problem in my code?</p>
