I want to create some simple tabs.
I have 3 divs with different content and I have positioned them on top of each other by setting a minus top-margin on the second two divs.
Then I have 3 tabs and I have set up my code so that when you click #tab1 .fadein content1.
Example:
$(document).ready(function() {
$(".content-kidsclub").hide();
$("#tab1").click(function() {
$(".content-kidsclub").fadeTo("slow", 1.0);
});
});
$(document).ready(function() {
$(".content-computersuite").hide();
$("#tab2").click(function() {
$(".content-computersuite").fadeTo("slow", 1.0);
});
});
$(document).ready(function() {
$(".content-education-assistance").hide();
$("#tab3").click(function() {
$(".content-education-assistance").fadeTo("slow", 1.0);
});
});
The first time I click each one it works well. but after that it just stops. And also: If you click tab2 first it is way above due to the minus margin. not sure why.
I feel so close yet so far. I have suspisions its something to do with callbacks.
I am very new to jQuery so this might seem a bit dumb what I am trying to do.
Overall does anyone know a better way to position divs on top of each other then get the tabs to work. Is it something to do with using display:block and all that sort of thing.
$(document).ready()function. You can do all of your tab stuff in one ready function.