[Vuejs]-How to add/remove class from parent div on change radio button in vuejs

-1👍

Like this? Example on Codesandbox

You basically want to use :class, for example:

<div class="parent" :class="{'green': radio}">
  <input type="radio" v-model="radio" :value="true"/> True
</div>
<div class="parent" :class="{'red': !radio}">
  <input type="radio" v-model="radio" :value="false"/> False
</div>

You can read more about it in the official Vue documentation:

Vue Documentation on Class and Style Bindings

Leave a comment