I'm struggling to get jQuery to assign the correct class per data value.
If the td .FuelInjectorQty has a value less than 3, it should add the class .FiJlowQty to the parent tr.FuelInjectorRow
If the td .FuelInjectorQty is greater than or equal to 3, it should add the class .FiJhiQty to the parent tr.FuelInjectorRow
if ($('.FuelInjectorQty').data('value') < 3) {
$('.FuelInjectorRow').addClass("FiJlowQty");
} else if ($('.FuelInjectorQty').data('value') >= 3) {
$('.FuelInjectorRow').addClass("FiJhiQty");
}
I have it half working, where it applies one or the other, but will not do it again for the second occurrence. Feel like I need a loop or something, so I was trying out each() but couldn't make it work.
$('.FuelInjectorRow').each(function(i) {
if ($('.FuelInjectorQty').data('value') < 3) {
$('.FuelInjectorRow').addClass("FiJlowQty");
} else if ($('.FuelInjectorQty').data('value') >= 3) {
$('.FuelInjectorRow').addClass("FiJhiQty");
}
});
See Fiddle: https://jsfiddle.net/bpo29/tmbp67nL/85/
Thank you for any pointers & help!!