[Vuejs]-How to use vue element class from JQuery?

2👍

You can directly do it in Vue, but if you wanted to use jQuery then you can write the jQuery code in the mounted or created hook. Also you can use the jQuery code in the methods as well.

new Vue({
  el: "#app",
  mounted () {
    $('.add').on('click',function() {
      alert('Add');
    });  
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="app">
  <button class="add">Button</button>
</div>

1👍

Don’t use jquery .. it’s easy to solve in vuejs

<button @click="alert('Add')">Button</button>
👤Hussam

Leave a comment