I'm trying to get the value of an element when a user click on it. This is my code:
<div id="heroes-selection" class="row dflex justify-content-left">
<figure id="luna" class="heroes-pic border text-danger m-3" value="heroes.luna">
<img class="animated-gif">
</figure>
<figure id="qop" class="heroes-pic border text-danger m-3" value="heroes.qop">
<img class="animated-gif">
</figure>
</div>
I've tried to use Jquery $(this) and the result came out as undefined.
$(".heroes-pic").on("click", () => {
player = $(this).attr("value");
console.log(player);
});
My goal is to get the value heroes.luna when the user click on the figure with id="luna". The same for id="qop", I need to get the value heroes.qop. Thank you!