The below code works perfectly, however, in Chrome the image which is in the class "platters-basket-update-button" moves down a few pixels when the button is clicked. It doesn't move again until the page is refreshed?
<div class="menu-two-column-product-main-cell-right-button-plus plus">
<a class="formqtyplus plus">+</a>
</div>
<div class="new-qty-box-update">
<input name="update" value="" type="submit" class="platters-basket-update-button">
</div>
<script>
$(document).ready(function(){
$(".input a").click(function () {
var inputEl = $(this).parent().parent().children().next().children();
var qty = inputEl.val();
if ($(this).parent().hasClass("plus"))
qty++;
else
qty--;
if (qty < 0)
qty = 1;
inputEl.val(qty);
})
});
</script>
How about adding return false on the click() function?
http://jsfiddle.net/fedmich/rh4Bw/1/
$(document).ready(function(){
$(".input a").click(function () {
var inputEl = $(this).parent().parent().children().next().children();
var qty = inputEl.val();
if ($(this).parent().hasClass("plus"))
qty++;
else
qty--;
if (qty < 0)
qty = 1;
inputEl.val(qty);
return false; //Prevents the "JUMP" on browser
})
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.