How to determine if an item has disappeared

I want to have two buttons: one to fade div1, and one to either fade div1 in, or fade the button itself if div1 is already hidden. here the code is pretty unnecessary, however, causing my main problem - the "if" statement ...

$('#b > button').click(function(){ $('#div1').fadeOut(400) }); $('#div2 > button').click(function(){ $('#div1').fadeIn(400) }); 
+4
source share
2 answers

Why not disable / enable buttons?

 $('#b > button').click(function(){ $('#div1').fadeOut(400, function() { $(this).prop('disabled', true); $('#div2 > button').prop('disabled', false); }); }); $('#div2 > button').click(function(){ $('#div1').fadeIn(400, function() { $(this).prop('disabled', true); $('#b > button').prop('disabled', false); }); }); 
+2
source

FadeOut just changes the display to none .

Check for display using jQuery $('selector').css('display')

+14
source

All Articles