我有一組數字字段。無論在該領域內的任何數字,我都希望顯示相同數量的div。當您將數字添加到數字字段時,應出現另一個div。當從數字字段中減去數字時,div應該消失。添加/刪除div作爲數字字段更改的計數
這裏是我的筆記 - 變化被設置爲測試目的警報:
$(document).ready(function() {
$('.product-quantity').on('change',function(){
alert('One of these is changed ' + $(this).attr('data-size'));
// Using the attributes of $(this), create selector to find input fields with this
size, belonging to this product
// If the count of those fields is > than the value we have of this, then we remove
// If it's < than, we add fields
// If it's equal, we do nothing
// we add/remove based on this dymanic selector
});
});
在我看來,如果你有你想要的東西的筆記,你應該能夠實現這些結果。你試過什麼了? –
做過這些對你有用嗎? – isJustMe