javascript - Vue.js - Add Class on Click Event -


i dynamically toggle class on click event on div in vue.js without using properties/data so.

here div

<div class="quiz-item" @click="checkanswer(1)">

when div clicked, add class quiz-item--correct or quiz-item--incorrect (the logic handled elsewhere). cannot use properties there many answers in quiz maintainable/viable approach.

does have ideas on how can achieve functionality?

you can this:

<div class="quiz-item" @click="$event.target.classlist.toggle('classname')"> 

you can check fiddle demonstrating this: here


Comments

Popular posts from this blog

python - RuntimeError: can't re-enter readline -

python - PyInstaller UAC not working in onefile mode -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -