我的 HTML
<div class="product-line">
<a href="#" alt="close" class="btn-close" title="Remove"><img alt="remove" src="img/close.png" /></a>
<input class="input-text" name="product-code" type="text" placeholder="Product Code" />
<input class="input-text" name="product-quantity" type="text" placeholder="Quantity" />
<input class="input-text" name="product-discript" type="text" placeholder="Discription of Product" disabled />
<label class="label-sign">£</label>
<input class="input-text price" name="product-price" type="text" placeholder="RRP Price" disabled />
<br>
</div>
我的 JS 代码行
price = $(this).parent("div.product-line").find("input[name=product-price]").val( Number(price).toFixed(2) * quantity )
基本上,如果我将例如 40.2 数量 3 相乘,我会得到类似 120.600000000.... 我如何将其限制为 2 个小数点。
数据通过 JSON(由其他人制作)传入。
我是JS新手