how to calculate each row with on change table <td><input> jquery
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<meta charset="utf-8">
<title>Example</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" class="qty"></td>
<td><input type="text" class="price"></td>
<td><input type="text" class="total" disabled></td>
</tr>
<!-- ...and so on... -->
</tbody>
</table>
<script>
(function() {
"use strict";
$("table").on("change", "input", function() {
var row = $(this).closest("tr");
var qty = parseFloat(row.find(".qty").val());
var price = parseFloat(row.find(".price").val());
var total = qty * price;
row.find(".total").val(isNaN(total) ? "" : total);
});
})();
</script>
</body>
</html>
Also in JavaScript:
- javascript object keys foreach
- jquery select input value empty and hasclass
- package json proxy
- discord js presence update
- remove from array javascript
- bookshelfjs npm
- javascript email validation
- js remove item array
- react how to export component
- date picker type react
- how to make an object stop at the end of your canvas p5js
- how to append data to a field in mongoose model
- jquery creating several items
- javascript regex match character from a set of characters
- relaod the page in express
- js constructor object
- javascript check undefined or null
- nuxt vuetify google fonts undefined
- capturar el valor de un input con jquery
- get current url in jsp page
- after click text editior open in javascript
- Material-ui Accessibility icon
- javascript html encode
- verify input is not Nan js