Leo
Leo

Reputation: 583

Is it possible to get the DOM element of a vuejs element?

Vue.js supplies a variable $el to return the whole template DOM element. Is it possible to get the "sub-element", in other words, the DOM element inside the whole template element?

For example, I want to show a floating window whose position depends on the current "mouse-over" element.

<div v-for="..." v-on:mouseover="showFloating(current_element)">

Is possible to get the DOM element "current_element"?

Upvotes: 3

Views: 1968

Answers (1)

ABDEL-RHMAN
ABDEL-RHMAN

Reputation: 3014

try this

<div v-for="..." v-on:mouseover="showFloating">

methods:{
    showFloating(event){
        console.log(event);
    }
}

this will give you the current element attributes`

Upvotes: 5

Related Questions