0👍
You need to put your method in,
methods: {
provjeriOdgovore() {
let questionDiv = document.getElementsByClassName("answer");
for (let i = 0; i < questionDiv.length; i++) {
let userInput = questionDiv[i].value.toLowerCase();
questionDiv[i].classList.add("color-white");
if (odgovori[i].includes(userInput)) {
console.log("tocno", questionDiv[i]);
questionDiv[i].classList.add("green-color");
if (questionDiv[i].classList.length > 2) {
questionDiv[i].classList.remove("red-color");
}
} else {
console.log("netocno", questionDiv[i]);
questionDiv[i].classList.add("red-color");
if (questionDiv[i].classList.length > 2) {
questionDiv[i].classList.remove("green-color");
}
}
}
},
},
and then call it… if you want it run on it’s own while rendering or creation call it in any lifecyclehook
- [Vuejs]-Why do sometimes white lines appear in my code like this?
- [Vuejs]-Button click event is not working using Vue.js framework
Source:stackexchange.com