jQuery UI, Location hash without page anchor jumping to element ID

If you’re using jQuery UI tabs and you don’t want the page to jump to that tab element, here’s how to do it:
1
2
3
4
5
6
7
$('#tabs').tabs();

$('#tabs ul li a').click(function(e) {
    var pos = $(window).scrollTop();
    location.hash = $(this).attr('href');
    $(window).scrollTop(pos);
});

Leave a Reply

Your email address will not be published. Required fields are marked *

*


7 + = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>