I have two buttons on my website. Next and previous. I want to write a code to increase the value each time next is clicked and decrease the value each time previous is clicked. I want the value to be shown in an input. But the value shown in input is always 0 and does not change with clicks.
Here is my code:
function count(){
var $counter=0;
$(".next-button").click(function() {
$counter=$counter+1;
});
$(".previous").click(function() {
$counter=$counter-1;
});
return $counter;
}
document.getElementById('counter').value =count();