Prevent auto scrolling when clicking tab anchor
- by JohnCrossy
On my page I have some tabs that I've added some javascript so when they're clicked the page loads the tab's anchor URL instead of simply changing the view with AJAX, but I now want to stop the browser from auto scrolling to the anchor location.
Having done some research, I'm pretty sure I just need to add a couple of lines so that when clicked it returns false or prevents default but, being a noob, I've no idea where to put them!?!
I know it's cheeky, but if any answers could include the full script (ie. the below) with the solution, that way I'll understand better and hopefully learn some valuable lessons also :)
Here's the code I'm using:
jQuery( function() {
jQuery('.ui-tabs').bind( 'tabsselect', function( e, ui ) {
window.location.hash = ui.tab.hash });
});