Update:
It looks more like $displayWall is a global JS variable (otherwise <a href='javascript:showComments($displayWall[id]);'> would not work). Then this should actually work too:
$('#linkId').click(function() {
showComments($displayWall[id]);
});
I realize now, that the following assumption is far fetched, but nevertheless:
Assuming $displayWall is a server side variable, meaning the page gets pre-processed.
You could, for example, set the ref attribute of the link to the variable value:
<a id="linkId" ref="$displayWall[id]">test</a>
and access it in the click handler:
$('#linkId').click(function() {
showCmments($(this).attr('ref'));
//...
});
If you are attaching the handler to one element only, you can also set the variable inside the click handler:
$('#linkId').click(function() {
var value = '$displayWall[id]';
//...
});