apply JavaScript to all elements with id
<pre><code>&lt;a id="link" href="http://www.google.co.uk"&gt;link&lt;/a&gt;

&lt;a id="link" href="http://stackoverflow.com"&gt;link&lt;/a&gt;
</code></pre>

<p>the javascript only replaces the first <code>href</code> but i want it to apply to any and all <code>&lt;a&gt;</code> with the <code>id="link"</code> <strong>OR</strong> do you have a <strong>jQuery</strong> alternative?</p>

<pre><code>&lt;script&gt;
var link = document.getElementById('link');
var src = link.getAttribute('href');
var paramurl = encodeURIComponent(src);
link.setAttribute("href", "http://mysite.com/?url=" + paramurl);
&lt;/script&gt;
</code></pre>
