can I use document.getElementById(someid).onclick for tag a
<p>I am trying to call a javascript function onclick. I have written something like this</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function readPage(){
        alert("Hello");
    }

    document.getElementById('read').onclick=readPage;
&lt;/script&gt;

&lt;a id="read" href=""&gt;read&lt;/a&gt; 
</code></pre>

<p>I am trying to call readPage function but its not working?if I write onclick inside  tag it works but the way I have written above is not working. why?</p>
