Javascript JQuery:Calculation插件不计算总价

Javascript JQuery:Calculation插件不计算总价,javascript,jquery,jquery-plugins,Javascript,Jquery,Jquery Plugins,:插件 主页: :javascript :html 页面加载后,我可以在total_price_ht字段中看到“$0.00”,但当我更改数量或价格时,它的值不会更改 我做错了什么?谢谢。我想每次你想重新计算总数时都需要调用calc插件: $("[id^='unit_quantity_'], [id^='unit_price_ht_']").keyup(recalc); function recalc() { $("[id^='total_price_ht']").calc(

:插件 主页:

:javascript

:html

页面加载后,我可以在total_price_ht字段中看到“$0.00”,但当我更改数量或价格时,它的值不会更改


我做错了什么?谢谢。

我想每次你想重新计算总数时都需要调用calc插件:

$("[id^='unit_quantity_'], [id^='unit_price_ht_']").keyup(recalc);


function recalc() {

    $("[id^='total_price_ht']").calc(
    // the equation to use for the calculation
    "qty * price", {
        bind: "keyup",
        qty: $("[id^='unit_quantity_']"),
        price: $("[id^='unit_price_ht_']")
    }, function(s) {
        // return the number as a dollar amount
        return "$" + s.toFixed(2);
    });
}

recalc();

示例:

您能发布生成的HTML吗?@AndrewHitaker我发布了生成的HTML。谢谢。谢谢——这就是你正在使用的插件吗?
<tr id="lines[0]">
  <td>
    <input id="0" type="checkbox" class="hiddenCheckbox">
    <label for="0" class="prettyCheckbox checkbox list"><span class="holderWrap" style="width: 18px; height: 19px; "><span class="holder" style="width: 18px; "></span></span></label>
  </td>
  <td>
    <input class="required" name="lines[0][title]" placeholder="Title" type="text">
  </td>
  <td>
    <input name="lines[0][description]" placeholder="Description" type="text">
  </td>
  <td>
    <input class="required" id="unit_quantity_0" name="lines[0][quantity]" placeholder="Quantité" type="text" value="0,00">
  </td>
  <td>
    <input class="required" id="unit_price_ht_0" name="lines[0][unit_price_ht]" placeholder="Prix unit. HT" type="text" value="0,00">
  </td>
  <td class="price" id="total_price_ht_0">$0.00</td>
</tr>
$("[id^='unit_quantity_'], [id^='unit_price_ht_']").keyup(recalc);


function recalc() {

    $("[id^='total_price_ht']").calc(
    // the equation to use for the calculation
    "qty * price", {
        bind: "keyup",
        qty: $("[id^='unit_quantity_']"),
        price: $("[id^='unit_price_ht_']")
    }, function(s) {
        // return the number as a dollar amount
        return "$" + s.toFixed(2);
    });
}

recalc();