2014-05-21 5 views
0

아래 코드는 완벽하게 작동하지만 Chrome에서 버튼을 클릭하면 "platters-basket-update-button"클래스의 이미지가 몇 픽셀 아래로 이동합니다. 페이지가 새로 고침 될 때까지 다시 이동하지 않습니까?클릭시 Google 크롬 브라우저에서 이미지가 아래로 이동

<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> 

답변

0

어떻게 클릭() 함수에 거짓 수익을 추가하는 방법에 대한?

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 
    }) 
});