Reputation: 79
I have Html code
<div id="demo" style="display:none;">Test demo</div>
and javascript:
$("#demo");
It will be selected, but I want to div with id = "demo", can not be selected because it's hidden.
Thank's
Upvotes: 1
Views: 3867
Reputation: 2523
For selecting hidden use $(':hidden#demo')
For selecting Visible use $(':visible#demo')
Upvotes: 0
Reputation: 53709
If I understand correctly and you only want to select #demo
if it's not hidden, use $('#demo:visible')
. Some helpful resources are https://api.jquery.com/visible-selector/ and https://api.jquery.com/hidden-selector/
Upvotes: 5