Vue.js set checkbox checked


We can set checkbox checked in vue.js using v-model.


Vue.js set checkbox checked Example

Set v-model to true to make checkbox as checked. Here is an example of checkbox checked state.-

Example:

<div id="app">
	<p><input type="checkbox" name="myCheckbox" v-model="myModel"/></p>
	<p>{{isChecked}}</p>

	<button @click="myFunction()">Click Me</button>
</div>
<script>
 new Vue({
el: '#app',
  
  data: {
	  myModel:false
  },  
   methods:{
    myFunction: function () {		
		this.myModel = true;
		
    }
	}

});
</script>

Try it »

Output of above example-

Vue.js set checkbox checked Example

Advertisements

Add Comment

📖 Read More