User123 User123 - 1 year ago 116
jQuery Question

JQuery - Filtering elements by attribute in jquery each

I'm trying to push data-type value of all visible rows into an array how do I do it using jquery?

I did something like this but I'm pretty sure its incorrect as its not working.

var myArray = [];

$('#myTableId tbody tr').each(function() {

Answer Source

use map() and use not() before looping

var myArray =  $('#myTableId tbody tr').not('.hidden').map(function(){
   return $(this).data('type')

You could do same with $.each also...the not() would remain the same

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download