title: Modifying the onclick event with jQuery
body: <p>I've got a javascript snippet that displays a widget on my page.  There's some links that get output by the script that look like this:</p>
  
  <pre><code>&lt;a href="#" onclick="somefunction()"&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>These links cause some JS to fire. That's great. The problem is the <code>href="#"</code> and the absence of a <code>"return false;"</code> at the end of the <code>onclick</code> attribute.  </p>
  
  <p>When I click one of those links, the browser jumps to the top of the document.  With the widget positioned close to the bottom of the document, this is no good.</p>
  
  <p>Unfortunately, I have no control over the output of the script.</p>
  
  <p>Using jQuery I can reference these links using <code>$("#wxheader ul li a")</code>. I tried the following code but it doesn't work:</p>
  
  <pre><code>$(document).ready(function(){
      $("#wxheader ul li a").each(function(){
          var onclick = $(this).attr("onclick") + "; return false;";
          $(this).attr("onclick", onclick );
      });
  });
  </code></pre>
  
  <p>I want to write a jQuery function that will change each onclick attribute to append <code>"return false;"</code> and it has to run after the script has output the content to the page.</p>
  
  <p>Any ideas?</p>