1
我想要將選定的產品與數量和價格放在另一個div標籤使用jquery點擊功能。 Evertime我點擊它只顯示變量「product」的第一個數組值。JavaScript選擇當前格
如何爲表格選擇當前行的值。
嫩枝模板
<tr>
<td class="reference">{{product.reference}}</td>
<td class="product">{{product.productNr}} </td>
<td class="product">{{product.productDesp}} </td>
<td class ="price">{{product.price}}</td>
<td class="input"><input type="text" /></td>
<td class="warenkorb"><button type='submit'>in den Warenkorb</button></td>
</tr>
<div id ="cart">
<!-- Here comes the selected product by the user -->
????????
</div>
我的javascript:
$('.warenkorb').click(function(){
var reference =('.reference').text();
alert(reference);
});
});
數據:
------------------------------------------------------
| reference | product | ProductNr | quantity | price |
______________________________________________________
|Jack store| Apple | 12435436 | 7 | 70€ |
______________________________________________________
|bill store| Apple | 32534534 | 4 | 34€ |
______________________________________________________
我認爲正確的方式來處理,這是不是周圍的DOM元素移動,但具有某種用您的模板暴露的購物車變量。 – Matt