0👍
✅
Use event.target.id
<div id="foo" @click="clickFunction($event)"></div>
and
clickFunction(event){
alert(event.target.id)
}
const App = {
methods: {
clickFunction(event){
alert(event.target.id)
}
}
}
Vue.createApp(App).mount('#app')
#app { line-height: 1.75; }
[v-cloak] { display: none; }
<div id="app" v-cloak>
<button id="foo" @click="clickFunction($event)">Click Me!</button>
</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
Source:stackexchange.com