V
V
Vladimir Banduristov2018-06-03 00:14:18
Vue.js
Vladimir Banduristov, 2018-06-03 00:14:18

How to pass an element to @click?

There is a list

<li v-for="element in elements">
    <button @click="someFunctioin()">Click!</button>
</li>

How can I pass an element to someFunction() so that I can, for example, attach a certain class to it or do something with it at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Koteezy, 2018-06-03
@vtboren

It is passed by default, just accept the argument in the someFunction method - this will be the current el ( el.target )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question