Reputation:
I want to check if an element is hidden but the code below is not working properly.
if ( $(element).css('display') = 'none' ){
// element is hidden
}
Upvotes: 2
Views: 46
Reputation: 15846
The code is not working because you are using =
you need to use ==
.
$(element).css('display') = 'none'
will cause error because you are trying to do an assignment operation.
More elegant solution.
if (!$(element).is(':visible')){
// element is hidden
}
Upvotes: 1
Reputation: 490
hey in your code you have to put ==
if( $(element).css('display') == 'none' ){
}
Also you can use
$("#idElement").is(":visible")
Upvotes: 1