I have a number of divs on my page, which are hidden by default. Jobs can be selected by links (to "#job8, for example). I'm trying to use hashchange in my script to check the URL for the specific hash and then to display the appropriate div.
This is an example div
<div class="job-details" id="job8" data-jobid="8">
<p>Job 8</p>
</div>
This is my 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();
}
});