I have the following code:
var sum = 0;
$("#scLD > tbody > tr > td:nth-child(2)").each(function () {
var x = $(this);
if (x.parent().hasClass(/^onHandTdmm([0-9]+)$/)) {
var y = parseFloat(x.text(), 10) || 0;
sum += y;
}
if (x.parent().hasClass("onHandGrand")) {
x.html(sum);
sum = 0;
}
})
I am trying to search through a column and if any of the cells parent(the row) contains a certain class name followed by any single number to add it. So basically if the parent contains the class of onHandTdmm followed by any number (example onHandTdmm1). The regex I came up with (/^onHandTdmm([0-9]+)$/) just returns 0 in my function.