[Vuejs]-How to select element by attr in Vue JS

0👍

Try with $refs

Add your element to ref="yourRef", you can select it using by this.$refs.yourRef[0].$el in method

For Class styling you can use v-bind:class

-2👍

Using document.querySelector you can try like this

var element = document.querySelector('[data-row="'+ row + '"][data-cell="' + cell +'"]');
element.addClass('bg-red')

or use the class and style bindings

https://v2.vuejs.org/v2/guide/class-and-style.html

Leave a comment