Skip to content
Advertisement

how to add or remove class in vuejs 2 based on id

I want to add or remove class to an element based on id using vuejs, but this code applies the behaviour to all elements. How can I add/remove a class to the element by id? Thanks all in advance.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Here is an example of using components to achieve the behavior you are looking for:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement