Why won't this JS code work?
<p>Can anyone tell me why when I use the following code, clicking on "Click Here" doesn't cause an alert? Is there any way to do this without adding an onClick attribute to the div tag?</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;

 var clicker = document.getElementById("test");
 clicker.onclick = test;

 function test() {
  alert('Test');
 }

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="test"&gt;Click Here&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
