I'm trying to hide elements in a table by having a jQuery function run through each row, checking a row's class and hiding based on that. The problem I seem to be running into is the function will check the first row's class and base all other checks to hide on if that first check was true or false. Below is the function and the portion of the form
The form
<select id="select" onchange="eligibility_changed(this);" class="fieldsel">
<option value="Select One:">Select One:</option>
<option value=".ineligible">Ineligible</option>
<option value=".eligible">Eligible</option>
<option value=".confirmed">Eligible</option>
</select>
And the function
function eligibility_changed($this) {
jQuery(".fieldsel").each(function() {
var col = this.id;
var val = this.value;
console.log(val);
if (val != "Select One:") {
jQuery("#tbl>tbody>tr").each(function() {
//Ran to check the row's class.
console.log(jQuery('#eligfld').attr('class'));
if (!jQuery( "#eligfld" ).is(val)) {
jQuery(this).hide();
}
});
}
});
};
#eligfldthen your jQuery will hide all elements with the same ID. Try also the jQuery:$('#eligfld ' + $this.val()).hide()