Jquery .next() function not working
Posted
by
Sundhar
on Stack Overflow
See other posts from Stack Overflow
or by Sundhar
Published on 2010-12-21T14:50:37Z
Indexed on
2010/12/21
14:54 UTC
Read the original article
Hit count: 107
jQuery
Guys i am trying to do something like this i have two href and a text box in the middle of those <-> TEXT <+> So when i press the - and + the value in the txt must increase or decrease by one
" value="<%=addProduct.getInteger("ATR_WebMinQuantity",1)/addProduct.getInteger(MCRConstants.DM_ATR_LEGACY_CASE_VENDOR_PACK_SIZE,1) %>" name="ADD_CART_ITEM<>quantity" class="text" maxlength="3" />
--!>
and i am using a jquery to + and - the value in the text box. Whenever i press + its happening correctly but for - it takes the TEXT fields name instead of its value . Any solution for this to make it to take the value of the TEXT box Jquery used follows : $(".quantity .subtract").click(function () { var qtyInput = $(this).next('input'); var qty = parseInt(qtyInput.val()); if (qty > 1) qtyInput.val(qty - 1);
qtyInput.focus();
return false;
});
$(".quantity .add").click(function () {
var qtyInput = $(this).prev('input');
var qty = parseInt(qtyInput.val());
if (qty >= 0 && (qty + 1 <= 999))
qtyInput.val(qty + 1);
qtyInput.focus();
return false;
});
© Stack Overflow or respective owner