I am hiding rows for given id
s using this code:
var idArray = ['A123','B456']; // getting from web services
for (var i=0;i<idArray.length;i++) {
var id = idArray[i];
$("#eTable tr[data-empid=" + id + "]").hide();
}
HTML (Just for example doesn't needs improvement)
<table id="eTable">
<tr data-empid="A123" data-salary="120" data-status="drone">
<td>Peter</td>
<td>Vogel</td>
<td>Principal</td>
</tr>
<tr data-empid="B456" data-salary="130" data-status="worker">
<td>Jan</td>
<td>Vogel</td>
<td>General Manager</td>
</tr>
<tr data-empid="C789" data-salary="110" data-status="worker">
<td>Jason</td>
<td>van de Velde</td>
<td>Company nurse</td>
</tr>
</table>
How can we improve this code as it is selecting same table again and again to get row one by one instead of getting them once?