Jquery - tell when the hash changes?

后端 未结 5 985
野趣味
野趣味 2021-01-03 15:29

I\'m trying to make my site respond correctly to the back button. I\'ve saved that hash of what I want it to do, but I don\'t know the hook for jQuery to be able to tell wh

5条回答
  •  独厮守ぢ
    2021-01-03 16:00

    After the document is ready, you examine the hash and alter the page appropriately.

    I don't know the hook for jQuery to be able to tell when the hash changes

    You can intercept your hash anchors' click events and respond appropriately as opposed to waiting for a "the hash has changed" event (which doesn't exist).

    Some approaches create a "the hash has changed" event by inspecting window.location.hash on a timer.

提交回复
热议问题