Yes ive been told a couple of time using onclick
$('#linkId').click(function()
instead of
<a href='javascript:showComments($displayWall[id]);'>
But then how do i store a variable in the function, like i can do with that above?
I mean if a link is like this: <a id="linkId">test</a> where can i store a variable?
Update:
It looks more like
$displayWallis a global JS variable (otherwise<a href='javascript:showComments($displayWall[id]);'>would not work). Then this should actually work too:I realize now, that the following assumption is far fetched, but nevertheless:
Assuming
$displayWallis a server side variable, meaning the page gets pre-processed.You could, for example, set the
refattribute of the link to the variable value:and access it in the click handler:
If you are attaching the handler to one element only, you can also set the variable inside the click handler: