Skip to content
Advertisement

Multiple buttons with same function call, but alert only showing for the first button

I’ve been messing around with Vue.js and Django and I added a function call to a button. The button is shown multiple times for each different type of food there is, but the alert is only shown when the very first button is clicked. What could be the cause?

Django template:

JavaScript

JS:

JavaScript

Advertisement

Answer

Figured it out. I had the divinside the for loop so it was creating a new div for each button.

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