Instead of passing the ID, you can just pass the element itself:
<link onclick="doWithThisElement(this)" />
Or, if you insist on passing the ID:
<link id="foo" onclick="doWithThisElement(this.id)" />
Here’s the JSFiddle Demo: http://jsfiddle.net/dRkuv/