I got this simple function that counts clicks (plus or minus). It works correctly.
The fact is that negative values appear with the minus symbol in front of them (eg. -3
), but it's not the same for positive ones.
Is there a way to have positive results show the plus symbol at the beginning (eg. +3
)?
$('#increase').click(function() {
$('#output').html(function(i, val) {
return val * 1 + 1
});
});
$('#decrease').click(function() {
$('#output').html(function(i, val) {
return val * 1 - 1
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="increase" type="button">+</button>
<button id="decrease" type="button">-</button>
<div id="output">10</div>