I am working on a static webpage that hides/shows particular sections of content when according buttons are clicked (I should mention I'm very new to jQuery).
As of now, it is not possible to directly visit a section by means of an URL. Is there a way to achieve this?
For instance, visiting http://www.mypage.com/#contact would automatically show the according section/div (and hide all others).
thanks!
HTML:
<a href="#home" id="button_home">Home</a>
<a href="#contact" id="button_contact">Contact</a>
<div id="section_home">some text</div>
<div id="section_contact">some text</div>
jQuery:
$(document).ready(function(){
$("#button_home").click(function(){
$("#section_home").addClass("visible");
$("#section_contact").removeClass("visible");
});
$("#button_contact").click(function(){
$("#section_home").removeClass("visible");
$("#section_contact").addClass("visible");
});
});