目标是 onClick 更改输入和显示的价格。下面的代码适用于 jquery 1.3.0,但不适用于 1.10.1。我错过了什么?如果有更好的方法请告诉我。
$(document).ready(function () {
$("").click(update2);
});
function update2() {
var Myprice = $("#price").val();
$('#displayPrice').html('Price: ' + Myprice + '');
}
HTML 标记 -
<input type="hidden" name="price" id="price" class="item_price" value="$15.00">
</label>
<div id="displayPrice" name="displayPrice" class="form_total">Price: $25.00</div>
<div class="xsshirt">
<input id="size5" class="product-attr-size" name="size" type="radio" value="XSmall" onClick="document.getElementById('price').value='$25.00'" />
<label for="XSmall"></label>
</div>
<div class="sshirt">
<input id="size1" class="product-attr-size" name="size" type="radio" value="Small" onClick="document.getElementById('price').value='$25.00'" />
<label for="Small"></label>
</div>
<div class="mshirt">
<input id="size2" class="product-attr-size" name="size" type="radio" value="Medium" onClick="document.getElementById('price').value='$25.00'" />
<label for="Medium"></label>
</div>
<div class="lshirt">
<input id="size3" class="product-attr-size" name="size" type="radio" value="Large" checked="checked" onClick="document.getElementById('price').value='$25.00'" />
<label for="Large"></label>
</div>
<div class="xlshirt">
<input id="size4" class="product-attr-size" name="size" type="radio" value="XLarge" onClick="document.getElementById('price').value='$30.00'" />
<label for="XLarge"></label>
</div>
</div>