I am very new to jquery – currently using it to show and hide content (divs) on a webpage when according buttons are clicked in a navigation-menu. I am roughly doing so as following:
$(document).ready(function(){
// show the "about" page
$("#aboutButton").click(function(){
$("#aboutPage").addClass("visible")
$("#contactPage").removeClass("visible")
});
// show the "contact" page
$("#contactButton").click(function(){
$("#aboutPage").removeClass("visible")
$("#contactPage").addClass("visible")
});
});
although I'd be eager to know how to approach this more clever, my most urgent problem is the brower's back-button that obviously doesn't play well with this. ideally I'd want it to work as expected: if it's pressed, I'd like to go back to the last visible section / div of my page. I am how ever suspecting that my approach is generally very wrong...
would be gracious for any hint! thanks