My goal is to use jQuery to toggle a button rather than the typical paragraph toggling. I want the button to appear and disappear when clicked, while also increasing the "score" upon each click and decreasing it when the button reappears. Can anyone guide me on how to achieve this?
While I have multiple buttons, I will share the code for one of them here.
HTML:
<li><button id="active1" onclick="disappear1()"></button></li>
JavaScript:
function disappear1() {
$("#active1").toggle();
currentStreak++;
document.getElementById("streak").innerHTML="current streak: " + currentStreak;
}
The issue I am facing is that once the button disappears upon clicking, there is no way to reference it afterward. I am looking for a solution that allows me to still access the button even after it vanishes.