A
A
Andrej Sharapov2019-07-09 14:00:52
Vue.js
Andrej Sharapov, 2019-07-09 14:00:52

How to add active class on button click?

Good afternoon!
I'm still new to vue, so I'm asking for your help and advice.
Task:
1. add an active class to the block by clicking on the button
2. when you click on the button again, or in another part of the body , hide the block (remove the class)
Conditions:
1. There is a button that has the following structure:

<button id="toggle" type="button" @click="show"></button>

2. Hidden block:
<div id="bar" :class="active: isActive"></div>
According to my assumptions, the event @click="show"should activate :class="active: isActive". But I don't understand how to combine button and block.
Operating time:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-07-09
@Madeas

https://jsfiddle.net/cjf14ek3/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question