Im trying to make an accordion with toggle which seems to work pretty good now. What i would like to get some help with as a newbie to javascript is the way it is put together.
This isnt pretty i know…
$(document).ready(function() {
$('#contact').click(function() {
$('#content2, #content3').hide(200, 'linear');
$('#content').toggle(700, 'linear');
});
});
$(document).ready(function() {
$('#services').click(function() {
$('#content, #content3').hide(200, 'linear');
$('#content2').toggle(700, 'linear');
});
});
$(document).ready(function() {
$('#about').click(function() {
$('#content, #content2').hide(200, 'linear');
$('#content3').toggle(700, 'linear');
});
});
I’d suggest:
JS Fiddle demo.
References:
click().nextAll().not().siblings().toggle().