I'm using hashchange jQuery plugin from http://benalman.com/projects/jquery-hashchange-plugin/ to hook up an event when the window's location.hash changes.
I'd like to trigger a function when the hash changes that passes the new hash value (obtained with event.fragment) and the current hash value (the value just before the event is fired).
Here's a snipped of what I'd like to achieve:
$(window).bind('hashchange', function(event){
   myFunction(event.fragment, /* currentHash */);
});
Is开发者_高级运维 this possible?
There's a property on location:
$(window).bind('hashchange', function(event){
   myFunction(event.fragment, location.hash);
});
Or, store it yourself:
var lastHash = location.hash;                 //set it initially
$(window).bind('hashchange', function(event){
   myFunction(event.fragment, hashLash);      //previous hash
   lastHash = location.hash;                  //update it
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论