title: Overwriting onclick value using jQuery
body: <p>I'm attempting to create a function that will select all anchor tags with both http and _gaq (because a lot of the links have event tracking on them), and then add Google Analytics <a href="https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite" rel="nofollow">cross-domain tracking linker method</a> to the onclick event:</p>
  
  <pre><code>        $("a[href*='http:'][onclick*='_gaq']").each(function(){
              var href = this.href;
              var onclick = $(this).attr('onclick');
              var linker = "['_link', "+ "'"+href+"'"+"],";
              var output = [onclick.substr(0,10), linker, onclick.substr(10), " return false;"].join('');
  
              console.log('output : '+output);
           });
  </code></pre>
  
  <p>When I run this, it outputs: </p>
  
  <p><code>output : _gaq.push(['_link', 'http://google.com'],['_trackEvent','dude','dude','dude']); return false;</code></p>
  
  <p>This is what I'd like the new value for onclick to be, so I'm wondering how can I have the output value 'overwrite' the old onclick value?</p>
  
  <p>I've also created a <a href="http://jsfiddle.net/5EVMp/" rel="nofollow">jsfiddle</a> to illustrate.</p>
  
  <p>Appreciate any help or suggestions. </p>