slideToggle and :visible

后端 未结 2 1598
轮回少年
轮回少年 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

提交回复
热议问题