Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery函数无法处理新添加的行_Javascript_Jquery - Fatal编程技术网

Javascript jQuery函数无法处理新添加的行

Javascript jQuery函数无法处理新添加的行,javascript,jquery,Javascript,Jquery,我想用jquery做一个简单的实时计算器,不需要刷新页面 我用jquery添加了动态表行,并在输入字段中应用了一些方法,但在新添加的行中,这并不能很好地工作 仅当我更改默认行中的某些内容时,新添加的行才起作用 以下是我的html代码: <button type="button" id="addBillingRow" class="btn btn-success btn-sm fa fa-plus fa-3x float-right">add</button> <t

我想用jquery做一个简单的实时计算器,不需要刷新页面

我用jquery添加了动态表行,并在输入字段中应用了一些方法,但在新添加的行中,这并不能很好地工作

仅当我更改默认行中的某些内容时,新添加的行才起作用

以下是我的html代码:

<button type="button" id="addBillingRow" class="btn btn-success btn-sm fa fa-plus fa-3x float-right">add</button>

<table class="table table-bordered" id="dynamic_field_shipping">
  <thead>
    <tr>        
      <th width="10%">Date</th>
      <th width="20%">Purpose</th>
      <th width="20%">Amount</th>
      <th width="10%">Quantity</th>
      <th width="30%">Total</th>
      <th width="10%">#</th>
    </tr>
  </thead>
  <tbody>
    <tr class="ship_bill">
      <td>
        12/12/17
      </td>
      <td>
        <input id="purpose" type="text" name="purpose" required>
      </td>
      <td>
        <input id="amount" name="amount" type="text" 
               oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" required>
      </td>
      <td>
        <input id="quantity" name="quantity" required="required" type="number" min="0" value="0">
      </td>
      <td>
        <strong><i><span class="multTotal">0.00</span></i></strong>
      </td>
      <td>
      </td>
    </tr>
  </tbody>
</table>
<table class="table table-bordered">
  <tbody>
    <tr>
      <td width="50%"><strong><i>Bill Amount:</i></strong></td>
      <td><strong><i><span id="grandTotal">0.00</span></i></strong></td>
    </tr>
  </tbody>
</table>
试试这个

 $("tbody").on('change', '.ship_bill input', multInputs);

谷歌事件delegation@PranavCBalan如果正确,此问题已被回答多次。对于数字输入,使用
type=“number”
step=1
进行讲座很容易,但演示示例很难,并且您已成功完成了困难的工作。谢谢!我在('change','tr',multi-nputs)上尝试使用$(“.ship\u bill input”);这没用。现在我明白了。再次感谢。
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"
 $("tbody").on('change', '.ship_bill input', multInputs);