How can I trigger a function when the URL changes? I try something like:
$(windows.location).change(function(){
//execute code
});
So my URL is something like http://www.mysite.com/index.html#/page/1. How can I execute jQuery or JavaScript code when the URL becomes something like http://www.mysite.com/index.html#/page/2?
That would be a
hashchangeevent, so I’d suggest:JS Fiddle demo.
References:
on().