V
V
Vanya Huk2017-07-05 20:25:31
Vue.js
Vanya Huk, 2017-07-05 20:25:31

How in vue.js on click on an element to add an attribute to it from a method?

<a v-on:click="click_page( this )" v-else href="javascript:void(0)" >{{page.page}}</a>

methods : {

            click_page   : function ( e ) {

                console.log( e  )
            }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yeldos Adetbekov, 2017-07-06
@vanyahuk

template
js

methods : {
    click_page(e){
        console.log(e)
        e.target.setAttribute("attributeKey", "attributeValue")
    }
}

E
Evgeny Kulakov, 2017-07-06
@kulakoff Vue.js

It's not entirely clear what you want.
If you get event into a function on click, then simply:
Or
Or

<a v-on:click="click_page($event)" href="javascript:void(0)">{{page.page}}</a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question