2

I want to get the element on which the click event is attached. But whenever I click and try to access event.target it only returns the exact clicked element. So, when I click on a child element, I get only the child element. not it's parent which has the click event. In normal javascript I could send the target with this keyword. But it seems Vue Js has no way of doing this.

So, What I need is the Vue Js code of the pure javascript code below:

function clicked(element){
  console.log(element.getElementsByTagName("ul"));
}
<li onclick="clicked(this)">
  <a href="#" class="d-block p-3 text-white outline-none w-100 h-100">
    <i class="icon-envelope"></i> Messages
  </a>
  <ul>
    .....
  </ul>
</li>

I want something like below:

methods: clicked(element){
  console.log(element.getElementsByTagName("ul"));
}
<li @click="clicked(this)">
  <a href="#" class="d-block p-3 text-white outline-none w-100 h-100">
    <i class="icon-envelope"></i> Messages
  </a>
  <ul>
    .....
  </ul>
</li>

0 Answers0