Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery include hidden divs in 'each'

Tags:

jquery

I need to find a way to include hidden divs in the each statement below. I can't seem to find the answer. It's not just for children of a hidden element so i'm not able to write it based on display:none

$("div").each(function(){
    if ($(this).hasScrollBar()){
        $(this).addClass('scrollable');
    }
});

hasScrollBar Function:

(function($) {
    $.fn.hasScrollBar = function() {
        return this.get(0).scrollHeight > this.innerHeight();
    }
})(jQuery);
like image 537
CoreyRS Avatar asked Feb 18 '23 01:02

CoreyRS


1 Answers

$('div')         finds all divs
$('div:hidden')  finds only hidden divs
$('div:visible') finds only visible divs
like image 141
gdoron is supporting Monica Avatar answered Feb 21 '23 02:02

gdoron is supporting Monica