Jquery Hashchange Example - Jquery

What is hashchange event in jquery?

Snippet Code


  
Rate this page :
  [ 1 votes]

Jquery hashchange is a simple event handler which enables the user for a very basic bookmarkable hash history via a cross-browser window.onhashchange event.

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src='http://benalman.com/code/projects/jquery-#change/jquery.ba-#change.js'></script> <script> $(function(){ $(window).#change( function(){ var # = location.#; document.title = 'The # is ' ( #.replace( /^#/, '' ) || 'blank' ) '.'; $('#nav a').each(function(){ var that = $(this); that[ that.attr( 'href' ) === # ? 'addClass' : 'removeClass' ]( 'selected' ); }); }) $(window).#change(); }); </script> <div align='center'> <p id="nav"> <a class="selected" href="#page1">page 1</a> <a class="" href="#page2">page 2</a> <a class="" href="#page3">page 3</a> <a class="" href="#page4">page 4</a> </p> </div>

Tags


Ask Questions

Ask Question