JSFiddle - React, Tailwind, and code Playground
HTML
<button class="generic">GENERIC</button>
JavaScript
// Declare the variable
var generic_counter = 0;
// Log the variable
console.log(generic_counter);
// When button is clicked, add 1 to the variable
$(document).ready(function() {
$(".generic").click(function(add_generic) {
if (generic_counter >= 5) {
alert("You've been looking up a lot about GENERIC, maybe contact this group?")
$(".generic").off("click");
} else {
generic_counter += 1;
console.log(generic_counter);
}
});
});
// So we have the thing counting up to 6 clicks, and then saying "blah"
// However, this keeps happening afterwards, so what we need is..
// The function needs to STOP when it reaches over 5