I have a dumb js question that has bothered me for quite some time but i never took the time to look into…
if I have a link (<a> tag) that I am just using to trigger a javascript action, I usually will say
<a href=“#” onClick=“some_js_code”>link text</a>
when i view the page and click this link, it jumps me to the top of the page which is annoying if the javascript i am triggering is something that triggers an animation at the current location (jquery slideDown or something)
I have gotten around this before with something liek this:
<a name=“someName”></a>
<a href=“#someName” onClick=“some_js_code”>link text</a>
but there has to be a better way… is there something else I can put in the href attribute to avoid this jumping to the top of the page?