I’ve set up a counter to track how many times a next and previous button is clicked.
- click = one
Previous Button Appears - click = nine
Next Button Disappears
I want to limit the amount the counter can be. For Example 10. Once it reaches 10.
// Buttons
var count = 0;
$("#mod3-6-1_nextbutton").click(function() {
$("#actions-container").css({
"top" : "-=110px"
});
count += 1;
counter();
});
$("#mod3-6-1_backbutton").click(function() {
$("#actions-container").css({
"top" : "+=110px"
});
count -= 1;
counter();
});
function counter() {
if (count == 0) {
$("#mod3-6-1_backbutton").css({
"top" : "-9999px",
"left" : "-9999px",
});
}
if (count == 1) {
$("#mod3-6-1_backbutton").css({
"top" : "20px",
"left" : "44px",
});
}
if (count > 9) {
$("#mod3-6-1_nextbutton").css({
"top" : "-9999px",
"left" : "-9999px",
});
$("#actions-container").css({
"top" : "-990px"
});
}
else {
$("#mod3-6-1_nextbutton").css({
"top" : "20px",
"left" : "700px",
});
}
}
This should get the work done for you
This will set the return value to false once the counter is 10 and your code will not get executed.. Once returned false;