I currently have an increment and decrement methods on 2 buttons. My increment function is firing fine however my decrement method is failing. I want to subtract just from the variable so an example would be if I had the class "move2" and fired the decrement method I would get "move1" and so on...d
Any thoughts?
let i = 0;
const increment = (div) => {
document.getElementById(div).classList.remove("move" + i++);
document.getElementById(div).classList.add("move" + i);
}
const decrement = (div) => {
var hasClass = document.getElementById(div).classList.contains('move1', 'move2')
if(hasClass === true)
document.getElementById(div).classList.remove("move" + i--);
}