mercredi 11 octobre 2017

How do I pass on checkbox id using v-on in Vue.js when checkbox is clicked?

this is my code:

<input type="checkbox" id="checklist-1-checkbox-1" v-on:click="addGreenClass(this)" name="checkbox1-1">

vue.js

new Vue({
  el: '#admin-dashboard',
  methods: {
    addGreenClass(element) {
      console.log(element);
    },
  }
});

In my console, I get the object referring to the whole document rather than referring to the input tag that the checkbox is sourcing the event from.

I'm sure I have the code wrong, but I can't seem to find my answer in similar questions that are asking for the code in pure Javascript in. Could someone help me here? Thank you.




Aucun commentaire:

Enregistrer un commentaire