0
votes

I'm trying to make a simple Jquery script that will fade out all divs where the class is 'content'. And then afterwards fade in the div that is passed through the div variable. It works, in the sense that it fades out and fades in the correct divs when a button is clicked. However it seems like the callback is not working - i.e. the fadeIn occurs at the same time as the fadeOut. Whats wrong with this code? I've looked through the Jquery tutorials and stuff but can't see why the callback won't work. Cheers

$(document).ready(function() {

    $(".buttons").click(function(event) {

        var div = this.name;

        $("#" + div).siblings(".content").fadeOut(1000, function() {

            $("#" + div).fadeIn(1000);

        });
    });
});
1
I'm not 100% sure this is what you mean, but it seems to work fine for me - jsfiddle.net/interdream/wZQRtJames Allardice

1 Answers

0
votes

Try:

$("#"+div).siblings(".content").fadeOut(1000).fadeIn(1000);