When using the sliderToggle
method, the :visible
expression never seems to return anything other than true.
If I manually use show
Your first (non-working) code fragment will be testing :visible
while slideToggle is mid-transition (more precisely, it tests it just after the transition starts.) Regardless of whether you're opening or closing, the mid-transition state will be :visible
- so you always get true
.
Try checking .is(":visible")
before calling slideToggle
Try adding a handler.
notes.slideToggle ("fast", function() {
var isVisible = notes.is(":visible");
});