I'm trying to get the swing of jQuery for an project and I pick up some things here and there but every now and then I hit a bumb.
On this jsFiddle you can see what I'm working on: http://jsfiddle.net/YpeeR/17/
jQuery(document).ready(function() {
jQuery('.toggle_hide').hide();
jQuery("#background_absolute_content li span").css('cursor', 'pointer').click(function() {
var $this = $(this);
$('.toggle_hide').not($this.next("div")).fadeOut(200, function() {
$this.next("div").fadeIn(200);
});
});
});
I have 4 divs hidden inside an li element. The div get shown when the user clicks on the span tag inside that li element where the div is and other div's get closed down. This works fine but I want to user to be able to toggle the current div too.
So when the user clicks an span in an li element the div that's hidden gets shown and when the user clicks on the same span again I want the div to hide again.
Unfortunately fadeToggle does not seem to do the trick propper as you can see here http://jsfiddle.net/YpeeR/18/ , but I can't seem to figure out why that is...