一個網頁有一些鏈接:jQuery:如何在hashchange事件處理程序中查找元素?
<a href="#example-hash-1" class="link">example-1</a>
<a href="#example-hash-2" class="link">example-2</a>
<a href="#example-hash-n" class="link">example-n</a>
點擊任何對他們的運行hashchange的情況下,我們要處理:
$(window).on('hashchange', function(event){
// Is it possible (inside this handler) to find out which of a.link was clicked?
});
或者,有另一種方式來做到這一點?
爲你的情況[event.target](https://api.jquery.com/event.target/)將做到這一點。 –
和'location.hash;'?即:'var hash = location.hash;' –