Inayat Kazi
Inayat Kazi

Reputation: 143

how to toggle a div on button click using "Id"

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

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

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

Related Questions