【问题标题】:How do i test if something is hidden with jQuery? [duplicate]我如何测试 jQuery 是否隐藏了某些东西? [复制]
【发布时间】:2012-09-26 12:51:27
【问题描述】:

可能重复:
Testing if something is hidden with jQuery

在 jQuery 中,假设您使用.hide().show().toggle() 隐藏和显示某种元素。您如何测试该元素当前在屏幕上是隐藏还是可见?

【问题讨论】:

    标签: jquery visibility


    【解决方案1】:

    试试

    $("some-selector").is(':hidden');
    

    $("some-selector").is(':visible');  
    

    这里是 :visible:hidden 选择器的文档。

    【讨论】:

      【解决方案2】:
      $('.target').is(':hidden') // returns true if the element is hidden
      $('.target').is(':visible') // returns true if the element is visible
      

      【讨论】:

        猜你喜欢
        • 2016-09-27
        • 1970-01-01
        • 2011-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多