I have multiple HTML buttons with the same class="preis"
.
<button class="preis" value="4,50">4,50€</button>
<button class="preis" value="5,50">5,50€</button>
<button class="preis" value="3,00">3,00€</button>
I want to output the value of the exact button I clicked in the console.log. I've tried this so far:
function output() {
console.log(price.value);
}
var price = document.getElementsByClassName("preis");
price.addEventListener("click", output, true);
and I want to avoid using different IDs for each button if thats possible.