1
옆에 소계를 형성한다.중력 내가 중력 주문 양식 유형의 시스템을 구축 할 제품 필드를 양식 사용하고 각 제품의 수량 JQuery와
나는 각 제품의 소계 (비용 * 수량)를 계산 옆 수량 jQuery를 통해 표시 할 노력하고있어. 여기
<script type="text/javascript">
$(document).ready(function() {
$('.gfield_price .ginput_container').append('<div class="product_subtotal">SUBTOTAL</div>');
$('.ginput_quantity').keypress(function() {
$x = $('.ginput_quantity');
$x.next('div.product_subtotal').html(this.value);
});
});
</script>
내 HTML의 코드 조각입니다 : 여기
내 jQuery를하다
<li id='field_5_12' class='gfield gfield_price gfield_price_5_12 gfield_product_5_12' >
<label class='gfield_label' for='input_5_12'>500 GPH Bilge Pump 24V</label>
<div class='ginput_container'>
<input type='hidden' name='input_12.1' value='500 GPH Bilge Pump 24V' class='gform_hidden' />
<span class='ginput_product_price_label'>Price:</span>
<span class='ginput_product_price' id='input_5_12'>$2.99</span>
<input type='hidden' name='input_12.2' id='ginput_base_price_5_12' class='gform_hidden' value='$2.99'/>
<span class='ginput_quantity_label'>Quantity:</span>
<input type='text' name='input_12.3' value='' id='ginput_quantity_5_12' class='ginput_quantity' size='10' tabindex='6'/>
</div>
</li>
당신은 그냥 값으로 product_subtotal의 사업부를 업데이트하기 위해 노력하고있어 현재 볼 수 있듯이 그 수량 필드에 입력됩니다. 나중에 실제 계산에 대해 걱정할 것입니다. 내 문제는) 내가 $ x.next (처럼 다음 div.product_subtotal을 선택하는 방법을 확실 해요 있다는 것입니다 모든 product_subtotal을 선택합니다.
그 트릭을했습니다. 고마워요! –
@JeffPurcell 당신은 오신 것을 환영합니다 :) – undefined