How to detect URL changes with jQuery

前端 未结 5 1751
梦谈多话
梦谈多话 2020-12-03 13:31

How can jQuery detect changes to a url?

For example: If a user goes to a page site.com/faq/ nothing shows, but if he goes to site.com/faq/#open

5条回答
  •  攒了一身酷
    2020-12-03 13:58

    Try This

    $(window).on('hashchange', function(e){
     // Your Code goes here
    });
    

    Its working for me

提交回复
热议问题