I'm trying to loop through table rows, pass in an object, grab each row's data-filter, and check it against the data I'm passing in (key value pairs). My below code isn't grabbing the data-filter value. What am I doing wrong?
HTML
<table id="table">
<tr data-filter="1">
<td></td>
</tr>
<tr data-filter="2">
<td></td>
</tr>
<tr data-filter="3">
<td></td>
</tr>
</table>
JS
$('#table > tr').each(function(data) {
var $this = $(this);
var filter = $this.attr(data-filter);
console.log(filter);
}