我有以下代码:
<div>
<input data-maxsale="9" data-maxsaleid="27595" name="cart[3839][qty]" value="1" title="Qty" class="input-text qty" maxlength="12">
<div class="maxsalenotifcation maxsaleid-27595">
<p>
placeholder
</p>
</div>
</div>
<div>
<input data-maxsale="3" data-maxsaleid="27757" name="cart[3841][qty]" value="1" title="Qty" class="input-text qty" maxlength="12">
<div class="maxsalenotifcation maxsaleid-27757">
<p>
placeholder
</p>
</div>
</div>
var maxSalInput = $('input[data-maxsaleid]');
$('.maxsalenotifcation').hide();
maxSaleInputs.each(function() {
var maxSaleID = $(this).attr('data-maxsaleid');
var maxSaleValue = $(this).val();
var maxSaleQuantity = $(this).attr('data-maxsale');
if (maxSaleValue > maxSaleQuantity) {
$('.maxsalenotifcation .maxsaleid-' + maxSaleID).show();
}
});
当输入值大于placeholder
时,我想为每个maxsaleid
单独显示maxSaleValue
。
如果需要,我可以修改html标记。
我该怎么做?
答案 0 :(得分:0)
compileSdkVersion
变量。maxSaleInputs
(类之间没有空格)代码段:
$('.maxsalenotifcation.maxsaleid-' + maxSaleID)
$(function() {
var maxSalInput = $('input[data-maxsaleid]');
$('.maxsalenotifcation').hide();
maxSalInput.each(function() {
var maxSaleID = $(this).attr('data-maxsaleid');
var maxSaleValue = parseInt($(this).val());
var maxSaleQuantity = parseInt($(this).attr('data-maxsale'));
if (maxSaleValue > maxSaleQuantity) {
$('.maxsalenotifcation.maxsaleid-' + maxSaleID).show();
}
});
});