Search the blog

To get a clicked element with Vue.js 2 first add a method in your component. Note the comment in the code below.

methods: {
    
    myFunction: (document, event) => {

        // This gets the clicked element as jQuery
        var $element = $(event.target);
        
    }
    
}

Then simply pass document and $event via @click.

<button @click="myFunction(document, $event)">Button</button>
Tim Bennett is a Leeds-based web designer from Yorkshire. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.