I have a table that has a column with Yes/No as possible values
<table id="mytable">
<thead>
<tr>
<th>
Col1
</th>
<th>
Col2
</th>
<th>
ActiveYN
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Apple
</td>
<td>
12345
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>
Orange
</td>
<td>
67890
</td>
<td>
No
</td>
</tr>
<tr>
<td>
Mango
</td>
<td>
456745
</td>
<td>
Yes
</td>
</tr>
I need to show the row if ActiveYN is 'Yes' and Hide id ActiveYN is 'No' How can i access the ActiveYN inside JQuery and show/hide accordingly?
You can do it from server side itself.
I don't know the razor syntax, but you get the idea.
To be able to do it from client-side, add a class.
And then in jQuery:
Edited again after your question was edited, now if we forget the server-side altogether:
Use this statement in your button click handler function. But, remember it will also find any text which contains "No" anywhere in a row. To make it more precise, use regular expressions to search exactly a "No".
usually I would add this as an attribute on the row:
Then to hide them all you can do:
Or you can add different classes/styles based on the value when it creates the table.
How about something like this:
$('td:contains("No")').parent().hide();
Live Demo
JS
HTML
DEMO