Reputation: 143
Below I have written code here I want to toggle a div while we click on this button by using vue.js. By using hidden data property I have tried but I want by using Id="categories" that div should toggle.
<button v-on:click="isHidden = !isHidden">categories</button>
<div id = "categories">While we click on above button I want to toggle this div on button click in vue.js using "Id"</div>
<script>
var app = new Vue({
el: '#app',
data: {
isHidden: false
}
})
</script>
Upvotes: 0
Views: 421
Reputation: 1
You don't need to use the id, just bind isHidden
to v-show
directive :
<div v-show="isHidden">While we click on above button I want to toggle this div on button click in vue.js using "Id"</div>
Upvotes: 1