I am trying to get the values of the span that are got clicked but I am either keep getting the undefined or "" blank string. I get blank string on $(this).text(); and $(this).val(); undefined.
Here is the codepen - https://codepen.io/xblack/pen/ypXPee
<div class="legends">
<div id="alpha" class="legend-cards">
<span class="legend-symbole">α</span>
<span class="legend-title-low title">LOW</span>
<span class="legend-value-low value">3657890</span>
<span class="legend-title-high title">HIGH</span>
<span class="legend-value-high value">3657890</span>
</div>
<div id="beta" class="legend-cards">
<span class="legend-symbole">β</span>
<span class="legend-title-low title">LOW</span>
<span class="legend-value-low value">3657890</span>
<span class="legend-title-high title">HIGH</span>
<span class="legend-value-high value">3657890</span>
</div>
<div id="gamma" class="legend-cards">
<span class="legend-symbole">γ</span>
<span class="legend-title-low title">LOW</span>
<span class="legend-value-low value">3657890</span>
<span class="legend-title-high title">HIGH</span>
<span class="legend-value-high value">3657890</span>
</div>
<div id="other" class="legend-cards">
<span class="legend-symbole">δ/θ</span>
<span class="legend-title-low title">DELTA</span>
<span class="legend-value-low value">3657890</span>
<span class="legend-title-high title">THETA</span>
<span class="legend-value-high value">3657890</span>
</div>
<div id="eegSense" class="legend-cards">
<span class="legend-symbole"><img src="img/pain.svg" style="width:50%" alt=""></span>
<span class="legend-title-low title">ATTENTION</span>
<span class="legend-value-low value">3657890</span>
<span class="legend-title-high title">MEDITATION</span>
<span class="legend-value-high value">3657890</span>
</div>
</div>
Javascript
$('.value').each((i,el)=>{
console.log(i,$(el).text(), $(el).closest('div').attr('id')); //this works
});
$('.title').on('click',()=>{
console.log($(this).val()); // this doesn't work
});
$('.value').on('click',()=>{
console.log($(this).text()); // this doesn't work
});