SoFunction
Updated on 2025-04-05

How to get the click event source for vue

Organize the document, search out a method of how to get the click event source for vue, organize it a little and streamline it to share it.

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <title>vue clickEvent gets the current element object</title>
    <script src="/ajax/libs/vue/1.0.13/"></script>
    <script src="/libs/jquery/2.1.4/"></script>
  </head>
  <body >
    <ul>
      <li v-on:click="say('hello!', $event)" style="background-color:blue;color:white;">Click the current line to get the next line</li>
      <li>li2</li>
      <li>li3</li>
    </ul>
    <script>
      new Vue({
        el: '#app',
        data: {
          message: 'Hello !'
        },
        methods: {
          say: function(msg, event) { 
            //Get the click object            var el = ;
            var li2text = $(el).next().text();
            alert("Content of the current object:"+$(el).text()+"Next line:"+li2text);
          }
        }
      })
    </script>
  </body>
</html>

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.