一个网页有一些链接: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;' –