Change hash without reload in jQuery

前端 未结 5 1788
耶瑟儿~
耶瑟儿~ 2020-12-04 17:23

I have the following code:

$(\'ul.questions li a\').click(function(event) {
    $(\'.tab\').hide();
    $($(this).attr(\'href\')).fadeIn(\'slow\');
    event         


        
5条回答
  •  孤街浪徒
    2020-12-04 18:11

    This works for me

    $('ul.questions li a').click(function(event) {
        event.preventDefault();
        $('.tab').hide();
        window.location.hash = this.hash;
        $($(this).attr('href')).fadeIn('slow');
    });
    

    Check here http://jsbin.com/edicu for a demo with almost identical code

提交回复
热议问题