small javascript solution need : is this line a valid code?
<p><strong>In Html file,I have many statements like this :</strong></p>

<pre><code>&lt;li class="menu"&gt;&lt;a href="#"&gt;1st menu&lt;/a&gt;&lt;/li&gt;
</code></pre>

<p><strong>And in javascript file,I have code like this :</strong></p>

<pre><code>1. function onload()
2. {
3.  var lists=document.getElementsByTagName("li");
4.  for(var i=0;i&lt;lists.length;i++){
5.      if(lists[i].className=="menu"){
6.          lists[i].a.onclick=genmenu;
7.      }
8.  }
9. }

function genmenu(){
    alert("this is an alert");
    return false;
}
</code></pre>

<p><strong>Problem  is, if i click on the link '1st menu', it doesn't show alert. But if i change the line 6 and write:</strong></p>

<pre><code>lists[i].onclick=genmenu;
</code></pre>

<p><strong>Then this link works and show alert.</strong></p>

<p><strong>My Question, Why line 6</strong>  (lists[i].a.onclick=genmenu;)  <strong>does'nt work? Isn't it a valid code?</strong></p>
