Append an onClick event to an anchor tag using jquery?
<p>I am trying to add an onClick event to an anchor tag ...</p>

<p>Previously i had ...</p>

<p><code>&lt;a href="somlink.html" onClick="pageTracker._link(this.href); return false;"&gt;</code></p>

<p>But i am trying to avoid the inline onClick event because it interferes with another script..</p>

<p>So using jQuery i am trying the following code ...</p>

<pre><code>&lt;script&gt;
    $(document).ready(function() {
      $('a#tracked').attr('onClick').click(function() {window.onbeforeunload = null;
        pageTracker._link(this.href); 
        return false;
      });
    });
&lt;/script&gt;
</code></pre>

<p>with the html like so <code>&lt;a id="tracked" href="something.html"&gt;</code></p>

<p>So my question is should this be working, and if not what would be the best solution?</p>
