title: unable to register onclick event handler
body: <p>I'm new to jquery and trying to play around with it. I want to register an onclick event on the the anchor link and avoid taking it to the next page. To do that I have written the following.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(function() {
              $('li &gt; a').onclick = hitme;
          });
          function hitme() {
              alert('You will not be able to go to the next page!!!');
              return false;
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;My First Heading with JQuery&lt;/h1&gt;
  
  &lt;p&gt;This is homepage wireframe!!!&lt;/p&gt;
  &lt;ul&gt;
      &lt;li&gt;&lt;a href="http://google.com"&gt;Click me and go to google!!!&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What am i doing wrong here?</p>
  
  <p><strong>update:</strong></p>
  
  <p>I changed the script from onclick to click but on the page load is taking me to the next page. I tried with event.stopPropogation and event.defaultPropogation but it is not working, here's my updated code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(function() {
              $('li &gt; a').get(0).click (function(event){
                  hitme();
                  event.preventDefault();
                  return false;
              });
          })
          function hitme() {
              alert('You will not be able to go to the next page!!!');
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>What stupidity am i doing?</p>