I'm trying to create a button click event. I usually use a value to check whether the button is already clicked, but some buttons have a different kind of value:
if (quizUrl.indexOf(tgt.value) === -1) {
if (tgt.value === 'Negeren') {
el.ClearArray(quizUrl)
if (tgt.classList.contains('activeMulti')){
tgt.classList.remove('activeMulti');
} else {
tgt.classList.add('activeMulti');
}
} else {
quizUrl.push(tgt.value);
for (let i = 0; i < buttons.length; i++) {
buttons[i].classList.add('activeMulti');
}
}
}
I've searched for a while but I couldn't find anything that worked or wasn't JQuery. The problem is about the part:
if (tgt.value === 'Negeren') {
Which means if the targeted value = negeren check if it has a certain class. If it has delete that class and if it hasn't add it. This should work like an on and off button, but for some reason it won't add the class and if I delete the else it adds it, but afther it does nothing. Does anybody know a solution?