0

<div class="reser-productlist">RESET</div>

<div class="checkbox-alignment-form-filter">
  <input type="checkbox" id="Coils" value="Coils" class="vh-product" v-model="checkedNames" />
  <label class="productlist-specific" for="Coils">Cs</label>
</div>

<div class="checkbox-alignment-form-filter">
  <input type="checkbox" id="Sheets" value="Sheets" class="vh-product" v-model="checkedNames" />
  <label class="productlist-specific" for="Sheets">Sts</label>
</div>

Based on v-on:click, How to uncheck/reset the checkbox,

Basically i want to uncheck the checkboxes, When user click on the RESET button/label. Generally to do this do i need to use the v-model or id or for in label to target and trigger the reset functionality?

2 Answers 2

1

I think you can use below code.

<div class="reser-productlist" @click="reset">RESET</div>
<script>
    export default
    {
        methods:{
            reset()
            {
                this.checkedNames = '';
            }
        }

    }
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

const App = new Vue({
el: '#app',
template: `<div>
  <div class="reser-productlist" @click="reset">RESET</div>

  <div v-for="product in products" class="checkbox-alignment-form-filter">
    <input type="checkbox" :id="product" :value="product" class="vh-product" v-model="checkedNames" />
    <label class="productlist-specific" :for="product">{{ product }}</label>
  </div>
  </div></div>
 `,
 data() {
  return {
    products: ['Coils', 'Sheets'],
    checkedNames: [],
  }
 },
 methods: {
  reset() {
    this.checkedNames = []
  }
 }
})
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<div id=app>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.