Reputation: 155
I have:
<div style="display:none;">
<div class="checkMe"></div>
</div>
when I now check .checkMe
if it is visible..
if($('.checkMe').is(':visible')) { ...
it is true although it is not
is there a way to achieve the check, without checking the parent-div?
Upvotes: 0
Views: 355
Reputation: 636
I am not sure about this answer
<div style="display:none;">
<div class="checkMe">child div</div>
</div>
<div id="samp"></div>
var element = jQuery('.checkMe').clone();
element.appendTo('#samp');
if($('.checkMe').is(':visible'))
{
alert('visible');
}
else
{
alert('not visible');
}
Upvotes: 1
Reputation: 3281
It is returning the correct value.
if ($('.checkMe').is(':visible')) {
console.log(true);
} else {
console.log(false);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div style="display:none;">
<div class="checkMe"></div>
</div>
Upvotes: 2