Please, note that the event window.onhashchange runs only in http://caniuse.com/hashchange.
It's only for the # changes on the url.
$(document).ready( function(){
$.url_menu_spy();
});
<ul class="nav">
<li data-urlmenuspy="index.html(#*)$" ><a href="#">Index</a></li>
<li data-urlmenuspy="#requirements$" ><a href="#requirements">Requirements</a></li>
...
</ul>
For other html you only need to change the class_select option to your change (ex: selected) and the sub_element_path.
data_urlspy_name: 'urlspy' - The name of the data tag.class_select: 'active' - The class to assign for the menu spy itemsub_element_path: '' - If it's assigned the script use the jQuery function find() to assign the class to another element according to this path.
This plugin is automatic...but if you need to use this functions...
$.findspymenu() - Find the Spymenu items and active them$.clear_active() - Clear all the active Spymenu items.