Reputation: 743
i needed to hide a div on my code behind:
bool hideDiv = false
//codes to change hideDiv
myDiv.visible = hideDiv;
and i want to check visibility of my div using javascript:
if (jQuery("myDiv") != null){
//some codes
}
else{
//some codes
}
and the 'jQuery("myDiv")' is always not null (even if the div was actually not visible), what is the better way to check if a div is visible?
Upvotes: 4
Views: 23594
Reputation: 150243
You can use :visible
selector inside is
filtering function:
if ($('#myDiv').is(':visible'))
Notes:
#
before the id in your selector(jQuery("myDiv")
).document.getElementById
Upvotes: 14