ユーザーが製品のポップアップ オーバーレイを更新してから閉じるたびに、注文の領収書を更新する関数を作成しています。この関数は、フォームの各入力を検索し、その値が より大きい場合、レシート div に情報を追加します0
。.html()
入力フィールドの上にあり、現在のアイテムを説明する label 要素の を取得し、これを領収書のアイテムの説明として使用しようとしています。
私は成功せずに使用しようとしました:
- $this.closest('label').html()
- $this.prev('label').html()
- $this.find('label').html()
- this.element.find('label').html()
これが私のコードです。私が話しているセクションは、「ラベルは」の部分です...
function updateOrder(){
var items = '';
$('input').each(function(){
var $this = $(this),
i_value = $this.attr('value');
if(i_value > 0){
items += $this.attr('id') + ' Quantity: ' + i_value + '<br/>'
+ 'label is: ' + $this.closest('label').html() + '<br/>';
}
});
$('#d_reciept').html(items);
}
およびサンプル フォーム アイテム
<tr>
<td class="td_thumbs">
<div>
<a class="fancybox" data-fancybox-group="vinyl-banners" href="img/products/vinyl-corporateblue.jpg"> <img src="img/products/thumbs/vinyl-corporateblue-thumb.png" alt="vinyl c-blue"/></a>
<label>Corporate Blue</label>
</div>
</td>
<td>6</td>
<td>
<input id="vinyl-blue" type="number" max="6" min="0" value="0"/>
</td>
</tr>