-
-
Save Joseph7451797/c7bf30b8feab645eddee991886c62a32 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/gukojef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.active { | |
color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.active { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script> | |
<div id="app"> | |
<div v-for="n in 10" @click="logElement($event)">{{ n }}</div> | |
</div> | |
<script id="jsbin-javascript"> | |
new Vue({ | |
data: { | |
elementOnClick: null | |
}, | |
methods: { | |
logElement: function(event) { | |
if(!!this.elementOnClick) { | |
this.elementOnClick.classList.remove('active'); | |
this.elementOnClick = null; | |
} | |
event.target.classList.add('active'); | |
this.elementOnClick = event.target; | |
}, | |
} | |
}).$mount('#app'); | |
</script> | |
<script id="jsbin-source-css" type="text/css">.active { | |
color: red; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">new Vue({ | |
data: { | |
elementOnClick: null | |
}, | |
methods: { | |
logElement: function(event) { | |
if(!!this.elementOnClick) { | |
this.elementOnClick.classList.remove('active'); | |
this.elementOnClick = null; | |
} | |
event.target.classList.add('active'); | |
this.elementOnClick = event.target; | |
}, | |
} | |
}).$mount('#app');</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
data: { | |
elementOnClick: null | |
}, | |
methods: { | |
logElement: function(event) { | |
if(!!this.elementOnClick) { | |
this.elementOnClick.classList.remove('active'); | |
this.elementOnClick = null; | |
} | |
event.target.classList.add('active'); | |
this.elementOnClick = event.target; | |
}, | |
} | |
}).$mount('#app'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment