Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

strategicsdemexico's avatar

Handle event mouseOver on Vue.js

How can i change the class of a div when the mouse is over it, with vue.js of course!

0 likes
3 replies
bostinait's avatar

Wouldn't it be simpler to use a CSS solution instead?

div:hover {whatever styles you want}

2 likes
bestmomo's avatar

Easy with vue.js, but also easy with simple css.

<div id="test" class="{ myclass }" v-on="mouseover: change">something there</div>

var vm = new Vue({
  el: '#test',
  data: {
    myclass: 'something'
  },
 methods: {
    change: function() {
      this.myclass = 'something else';
    }
  }
});

Change {..} to mustache {{...}}

Please or to participate in this conversation.