Check div is hidden using jquery

青春壹個敷衍的年華 提交于 2019-12-02 18:49:55

You can check the CSS display property:

if ($('#car').css('display') == 'none') {
    alert('Car 2 is hidden');
}

Here is a demo: http://jsfiddle.net/YjP4K/

Try:

if(!$('#car2').is(':visible'))
{  
    alert('car 2 is hidden');       
}

Try

if($('#car2').is(':hidden'))
{  
    alert('car 2 is hidden');       
}

Try checking for the :visible property instead.

if($('#car2').not(':visible'))
{
    alert('car 2 is hidden');       
}
smendola

Did you notice your typo, $car2 instead of #car2 ?

Anyway, :hidden seems to be working as expected, try it here.

You can use,

if (!$("#car-2").is(':visible'))
{
      alert('car 2 is hidden');
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!