agon024 agon024 - 1 month ago 16
CSS Question

jQuery - Exclude elements from object loop

So I am using this code to loop through the DOM and locate all elements that match and then add a class to the elements:

var timeDif = 0;


$('.panel-main').each(function () {
var $el = $(this);
setTimeout(function () {
},200 * timeDif);

}, 1000);

what I need to know how to do is exclude any elements that have an inline style of " style="display: none; ". Is this possible?

Thank you in advance.


Depending on your complete use case, you should use the jQuery visibility selector.

$('.panel-main:visible').each(function() {

This continues to work for elements that have that inline style, regardless if you show them or not.