Categories
Vue Answers

How to watch click events from a checkbox with Vue.js?

Spread the love

Sometimes, we want to watch click events from a checkbox with Vue.js.

In this article, we’ll look at how to watch click events from a checkbox with Vue.js.

How to watch click events from a checkbox with Vue.js?

To watch click events from a checkbox with Vue.js, we can watch the change event.

For instance, we write

<template>
  <input
    type="checkbox"
    :value="mainCat.merchantId"
    v-model="checkedCategories"
    @change="check"
  />
</template>

to watch the change event on the checkbox with @change="check".

Then check will run when we check or uncheck the checkbox.

Conclusion

To watch click events from a checkbox with Vue.js, we can watch the change event.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *