<span class="info">
<span> Child 1 </span>
</span>
<span class="info">
<span> Child 2 </span>
</span>
$('#result').on('click', 'span', function() {
var search = $(this).children(".info").val();
I want to access the text written inside the child element of the clicked element. It does not work with the .val function that wrote above because there is no value. How can I do it with innertext function ?
If the top span is clicked, the value of the search variable should be Child 1, if the bottom span is clicked, its value should be Child 2.
Thank you.