Determining if any divs are hidden in jQuery
-
29-06-2021 - |
Question
I have a RadTreeView with a custom NodeTemplate. Inside that node template, I have the node surrounded in a div
, like so:
<div id="divCommandRow">
<!-- My template goes here -->
</div>
After the RadTreeView renders, my DOM has several <div id="divCommandRow">
divs in the DOM. My question is, how can I use jQuery to query if any of these div's have display: none
style? I created the following code, but it doesn't seem to work:
function IsInEditMode() {
$('#divCommandRow').each(function () {
if ($(this).is(':visible'))
return true;
});
return false;
}
Any ideas on what I'm doing wrong?
Solution
$('selector').length == $('selector:visible').length
or
$('selector:not(:visible)').length == 0
With this condition you check if all the elements that match selector
selector are visible
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow