我已经尝试了下面给出的一些代码,但是 javascript 在 php 页面上不起作用。我是一个试图学习代码的新手。
<section id="cart_items">
<div class="container">
<div class="table-responsive cart_info">
<table class="table table-condensed">
<tbody>
<tr>
<td class="cart_quantity">
<div class="checkout">
<p class="price" data-price="4.99">$4.99 per Juice</p>
<p class="description">Quantity:</p>
<input type="text" class="quantity" value="1">
<p class="total">Total: <span id="total">$4.99</span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section> <!--/#cart_items-->
<!--/#do_action-->
<script>
$(document).ready(function(){
$(".checkout").on("keyup", ".quantity", function(){
var price = +$(".price").data("price");
var quantity = +$(this).val();
$("#total").text("$" + price * quantity);
});
});
</script>
Javascript不起作用,请在这方面帮助我。
慕容森
慕姐4208626
随时随地看视频慕课网APP