Skip to content
Advertisement

How to change style of element in click if its in a for loop in Javascript + Vue?

If I have an element like this that is in a for loop:

JavaScript

meaning that there is more than one of these elements, how can I change the style of the element that was clicked.

I have this function:

JavaScript

But this will change the style of all my <p> elements instead of just the one I clicked. How can I get around this?

Advertisement

Answer

You can use index or id if you have it in review object:

JavaScript
JavaScript
JavaScript
Advertisement