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

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -