Vue.Js toggle Class on click
home
Run
screen_rotation
fullscreen
cloud_download
<html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.0/vue.js"></script> </head> <body> <div id="app"> <div id="myDiv" v-bind:class="{ active: myClass }" v-on:click="myClass = !myClass"> CLick me </div> Active Class = {{myClass}} </div> <script> var App = new Vue({ el: '#app', data: { myClass: false } }); </script> </body> </html>
<html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.0/vue.js"></script> </head> <body> <div id="app"> <div id="myDiv" v-bind:class="{ active: myClass }" v-on:click="myClass = !myClass"> CLick me </div> Active Class = {{myClass}} </div> <script> var App = new Vue({ el: '#app', data: { myClass: false } }); </script> </body> </html>
Copyrights@tutorialsplane.com