Reputation: 555
I'm using to filter the records of a table the show/hide option with jquery.
$("tbody tr[data-ediction!='"+ed+"']").hide();
$("tbody tr[data-ediction='"+ed+"']").show();
In the <tr>
I add the data-edition and it value.
Could you help me please?
Upvotes: 0
Views: 457
Reputation: 2834
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
var ed=1;
$("tr[data-ediction='"+ed+"'][color='red']").hide();
$("tr[data-ediction='2']").show();
});
</script>
</head>
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr data-ediction='1'>
<td>Jill-show</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr data-ediction='1'>
<td>Eve--show</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr color='red' data-ediction='1'>
<td>Jill--hide</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr data-ediction='2'>
<td>Eve--show</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</body>
</html>
Upvotes: 1