I have several hidden divs on my webpage. Users can select jobs by clicking on links (such as "#job8"). I am attempting to use the hashchange function in my script to check the URL for a specific hash and then show the corresponding div.
Below is an example of one of the divs:
<div class="job-details" id="job8" data-jobid="8">
<p>Job 8</p>
</div>
This is the script I am using:
$(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();
}
});