I want to return matched element ID using jquery filter method but it is returning ‘object object’ fiddle
//css
.none{display:none}
//html
<div class="none">
<span style="display:none">first</span>
<span style="display:block">second</span>
</div>
//script
visibles = $('.none').find('span').filter(function(){
if($(this).css('display') == 'block')
return $(this).attr('id');
});
alert(visibles);
The callback you give to filter returns a value used to filter.
If you have only one match, use this :
If you want to get an array of the match ids, use
Demonstration