이것은 지난 4 시간 동안 내 마음을 아프게했다, 나는 단지 그것을 작동시킬 수 없다!jQuery - 두 개의 .text를 작동시키는 방법?
'.cd_price'대신 두 가지 기능이 있습니다. B & W를 선택하면 작동하지만 '.cd_quantity'를 변경하면 분명히 바뀝니다.
나는 'newPrice'를 숨겨진 범위에 넣으려고 시도했으나 거기에서 그 정보를 얻으려고했지만 막히지 않고 얻을 수 있습니다.
당신은 http://gilliesaudio.co.uk/store/products.html
에서 예를 찾을 수 있습니다 사전들에 정말 고마워요! 희망을 나는 어떤 정보도 놓치지 않고 있었다.
이 내 HTML입니다 :
<input type="text" value="50" min="50" class="item_Quantity cd_quantity">
<span class="item_price cd_price" data-base_price="0.53"></span>
그리고 이것은 내 jQuery를하다 :이
$(".item_print-colour").on("change", function() {
var base_price = $(".cd_price").data("base_price");
var addition = (this.value == 'B&W' ? 0.20 : 0);
var newPrice = (base_price + addition).toFixed(2);
$(".cd_price").text(newPrice);
});
/* CD START */
$(".cd_quantity").on("keyup", function() {
var base_price = $(".cd_price").data("base_price");
var discount = 0;
if (this.value > 99) discount = 0.09;
$(".cd_price").text((base_price - discount).toFixed(2));
if (this.value > 199) discount = 0.14;
$(".cd_price").text((base_price - discount).toFixed(2));
각 제품마다 별도의 기능이 있습니다. – user1122925