Programming Tips - jQuery: change an anchor from URL to function call

Date: 2024mar14 Language: javaScript Q. jQuery: change an anchor from URL to function call A. If you have:
<a id=myanchor href='http://example.com'>Example</a>
And you want it to call a function instead of going to the URL, do this with jQuery:
$('#myanchor').attr('href','javascript:void(0)').click(onClickAnchor);
This neutralizes the href. And will make it call function onClickAnchor() with the user clicks.