Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How to add a class to parent element when checkbox is checked in Vue.js 2.0

Is it possible to use a checked state of checkbox to add a class to parent div? If not, how to do it? Here is the code:

<div
   class="checkbox-container"
   v-for="item in items"
   :key="item.id"
   :class="{'checked': checkbox.checked}" // I wanna do something like that
>
   <input type="checkbox" :id="item.id" :value="item.value" v-model="checkedItems">
   <label :for="item.id">{{ item.text }}</label>
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just use the value from v-model

:class="{'checked': checkedItems.includes(item.value) }"
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!