I want buttons visibility to be toggled with display:none when i click .button1 I tried if statements but not working n' also how can i bind two or more buttons one style with vue
<template>
<div>
<div id="buttons">
<div class="button1" @click="showOthers()">1</div>
<div class="button2" v-bind:style="{ display }">2</div>
<div class="button3" v-bind:style="{ display }">3</div>
</div>
</div>
</template>
data(){
return {
display:'none'
}
},
methods: {
showOthers: function() {
this.display = "inline-block"
if(this.display == "inline-block"){
this.display = 'none';
}
}
}
*{
font-family: sans-serif;
}
#buttons div{
margin-top:5px;
text-align: center;
width:40px;
height:35px;
background: #333;
border-radius:15px;
color:white;
}
#buttons div:first-child{
display: inline-block;
}
if/elseinshowOthers? Otherwise you're testing whetherthis.displayisinline-blockjust after setting it toinline-block. Any reason why you're not usingv-iforv-showfor this?this.displayto"inline-block"then checkingif(this.display == "inline-block"), this if condition will always be true1right ?