You can use .filter() .
var displayed = $('mySelector').filter(function() { var element = $(this); if(element.css('display') == 'none') { element.remove(); return false; } return true; });
This will return all elements from your selector that the display attribute is not none , and remove those who are.
source share