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 -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -