JSFiddle - React, Tailwind, and code Playground
by timmah
HTML
<input type="checkbox" value="click me!" id="showHiddenRows"></input>
<table class="tableName">
<tr class='foo'>
<td>this row is hidden</td>
</tr>
<tr>
<td>this row is not hidden</td>
</tr>
</table>
JavaScript
$("#showHiddenRows").click(function() {
if($(this).is(":checked")) {
alert("showing"); //This pops up
$(".tableName").each(function() {
console.log('tablename');
$(".tableName tr.foo").each(function() {
console.log('found');
$(this).attr("style", "display: initial;");
alert("found a hidden row"); //This does not pop up...
});
});
} else {
alert("hiding");
//essentially the same code here, but display:none;
}
});