I'm trying to do quantity system and my code is :
<div class="sp-quantity">
<div class="sp-minus fff"> <a class="ddd" href="#">-</a></div>
<div class="sp-input">
<input type="text" class="quntity-input" value="1">
</div>
<div class="sp-plus fff"> <a class="ddd-plus" href="#">+</a></div>
</div>
<script>
$('.ddd-plus').click(function(){
var $old = $('.quntity-input').val();
var $plus =($old +1);
// var $minus = $old - 1;
$('input').val($plus);
console.log($plus,$old);
});
</script>
<style>.sp-quantity {
width:124px;
height:42px;
font-family:"ProximaNova Bold", Helvetica, Arial;
}
.sp-minus {
width:40px;
height:40px;
border:1px solid #e1e1e1;
float:left;
text-align:center;
}
.sp-input {
width:40px;
height:40px;
border:1px solid #e1e1e1;
border-left:0px solid black;
float:left;
}
.sp-plus {
width:40px;
height:40px;
border:1px solid #e1e1e1;
border-left:0px solid #e1e1e1;
float:left;
text-align:center;
}
.sp-input input {
width:30px;
height:34px;
text-align:center;
font-family:"ProximaNova Bold", Helvetica, Arial;
border: none;
}
.sp-input input:focus {
border:1px solid #e1e1e1;
border: none;
}
.sp-minus a, .sp-plus a {
display: block;
width: 100%;
height: 100%;
padding-top: 5px;
}
</style>
(by the way this code works only when I put the jquery to console,else it does not work.
So when I click plus, it should add 1 to input's value (example: if value of input it 1, it should 2 but it makes it 11)
How can I fix that? Thanks