Created
August 8, 2018 16:40
-
-
Save Ravaelles/1aa9275d6a38a00d9eef4b34efe280bd to your computer and use it in GitHub Desktop.
Vue.js checkbox controlling div visibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- development version, includes helpful console warnings --> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
</head> | |
<body> | |
<div id="app"> | |
<div id=""> | |
<input type="checkbox" id="toggleMe" v-on:click="toggleClick"> | |
<label for="toggleMe">Toggle me {{ message }}</label> | |
</div> | |
<div id="section" v-if="visible"> | |
Ha! Visible now! | |
</div> | |
</div> | |
<script> | |
var app = new Vue({ | |
el: '#app', | |
data: { | |
message: 'Hello Vue!', | |
visible: false | |
}, | |
methods: { | |
toggleClick: function() { | |
this.visible = ! this.visible; | |
}, | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment