ani_css ani_css - 2 months ago 7
Javascript Question

How to count dynamic submitting by button

I have html structure like this

enter image description here

<div class="count-box cocuk-count">
<span class="count-text">Çocuk:</span>
<span class="kisi-down"></span>
<span class="kisi-sayi-text">1</span>
<span class="kisi-up"></span>
</div>


and if I click first button (minus) it must counting forwards or if I click second button (plus) it must counting how can be possible by jquery ?

Answer

For addition

$('.kisi-up').click(function(){
   $('.kisi-sayi-text').html(parseInt($('.kisi-sayi-text').html())+1);
});

For substraction

$('.kisi-down').click(function(){
   $('.kisi-sayi-text').html(parseInt($('.kisi-sayi-text').html())-1);
});
Comments