1👍
here is your code working and I updated your fiddle
Adding the this
statement and adding the event
param inside optionButtonClicked
const ProgrammingLanguages = new Vue({
el:".pl_wrapper",
data:{
name: "aa",
show1: false,
show2: false
},
methods: {
optionButtonClicked(event){
var indexOfClicked = index(event.target,event.target.className);
this.show1 = (indexOfClicked==0) ? true : false
this.show2 = (indexOfClicked==1) ? true : false
console.log(this.show2)
}
}
});
function index(element,className){
var allElements = document.getElementsByClassName(className);
for (var i = 0; i < allElements.length; i++) {
if(allElements[i]==element){
return i;
}
}
}
Source:stackexchange.com