javascript - Hashchange to show divs -


i have number of divs on page, hidden default. jobs can selected links (to "#job8, example). i'm trying use hashchange in script check url specific hash , display appropriate div.

this example div

<div class="job-details" id="job8" data-jobid="8">     <p>job 8</p>         </div> 

this script.

$(document).ready(function(){          $('.job-details').hide(); });  $(window).bind('hashchange', function() {          if (location.hash.substring(0,4) == "#job"){             var jobid = location.hash.substring(0);              $('.job-details').hide();             $('[data-jobid="' + jobid + '"]').show();             }   }); 

your line:

var jobid = location.hash.substring(0); 

assigns '#' jobid. presumably isn't want? want:

var jobid = location.hash.substring(4); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -