This is my div
Then I have a Show button that will show the div when you click:
Try checking for the :visible property instead.
if($('#car2').not(':visible'))
{
alert('car 2 is hidden');
}
You can use,
if (!$("#car-2").is(':visible'))
{
alert('car 2 is hidden');
}
Try
if($('#car2').is(':hidden'))
{
alert('car 2 is hidden');
}
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/
Did you notice your typo, $car2
instead of #car2
?
Anyway, :hidden
seems to be working as expected, try it here.
Try:
if(!$('#car2').is(':visible'))
{
alert('car 2 is hidden');
}