How can I pass html class as a parameter in a Jquery function?

Viewed 46

I am trying to create a general purpose function for my code because I have a lot of repeated code that could be solved by creating only one function

the function below is the one that I am trying to create but is not working this function is supposed to accept HTML elements ( classes) as parameters

example:

<tr class=" propertyTaxes">
        <td>Property taxes</td>
        <td><input class="form-control inputAmount"  type="number" step="0.01" value="0.00"/></td>
        <td><input class="form-control interestRate" type="number" step="0.01" value="12.00" disabled /></td>
        <td><input class="form-control property60" type="number" step="0.01" value="0.00" disabled /></td>
        <td><input class="form-control property48" type="number" step="0.01" value="0.00" disabled /></td>
        <td><input class="form-control property36" type="number" step="0.01" value="0.00" disabled /></td>
    </tr>

I want to be able to pass propertyTaxes, as the first parameter, property60 as the second parameter, property48 as the third parameter, property36 as the fourth parameter, these parameters are html components which have a class, is this possible?

function generalFunction(
      parentHtml,
      childHtml1,
      childHtml2,
      chilHtml3,
      value,
      func
          ) {
                $(".parentHtml").each(function (i, obj) {
                var baseAmount = parseFloat($(this).find(".inputAmount").val());
                var totalInterest = parseFloat($(this).find(".interestRate").val()) / 100;

                arrearsVal = func(baseAmount, totalInterest);

                $(".childHtml1").val(value);
                $(".childHtml2").val(value);
                $(".chilHtml3").val(value);
                                     });
                                  }
0 Answers
Related