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

400
Views
I want to change the color of the <li> with a select option using vue.js

I'm new to vue.js and I am trying to change the background color using the select option. I tried this method cueCardsColor but still nothing happens

<ul>
  <li :class="+ cueCardColor"> 
    <select v-model="selected">
      <option v-for="option in options" v-bind:value="option.value">
        {{ option.text }}
      </option>
    </select>
  </li>
</ul>

here are the values and the method

new Vue({
  el: '...',
  data: {
    selected: 'Select color',
    options: [
      { text: 'Green', value: 'green' },
      { text: 'Red', value: 'red' },
      { text: 'Blue', value: 'blue' }
    ]
  },
computed:{
 cueCardColor() {
      if(this.selected!='Select color'){
        return this.selected.options
      }
    
    }

}
})

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You already have the color in this.selected:

new Vue({
  el: '#app',
  data: {
    selected: 'Select color',
    options: [
      { text: 'Green', value: 'green' },
      { text: 'Red', value: 'red' },
      { text: 'Blue', value: 'blue' }
    ]
  },
computed:{
 cueCardColor() {
      if(this.selected!='Select color'){
        return this.selected
      }
      return 'transparent'
    }

}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<ul>
  <li :style="{ 'background-color': cueCardColor }"> 
<select v-model="selected">

  <option v-for="option in options" v-bind:value="option.value">
    {{ option.text }}

  </option>

</select>
</li>
</ul>
</div>

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!