slideToggle and :visible

后端 未结 2 1591
轮回少年
轮回少年 2020-12-17 15:13

When using the sliderToggle method, the :visible expression never seems to return anything other than true.

If I manually use show

相关标签:
2条回答
  • 2020-12-17 15:40

    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

    0 讨论(0)
  • 2020-12-17 15:44

    Try adding a handler.

    notes.slideToggle ("fast", function() { 
      var isVisible = notes.is(":visible");
    });
    
    0 讨论(0)
提交回复
热议问题