document ready function plus on click function var val parseInt counts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$(document).ready(function () {
$('.plus').on('click',function () {
var val = parseInt($('#counts').val());
if(val < 100){
$('#counts').val(val + 1);
if(val + 1 == 100) $('.plus').addClass('active');
else {
$('.plus').removeClass('active');
$('.minus').removeClass('active');
}
}
});
$('.minus').on('click',function () {
var val = parseInt($('#counts').val());
if(val > 1){
$('#counts').val(val - 1);
if(val - 1 == 1) $('.minus').addClass('active');
else{
$('.plus').removeClass('active');
$('.minus').removeClass('active');
}
}
});
});