I have the following code:
<div class="tipo-cadastro">
<div class="box-logista active">Logista</div>
<div class="box-distribuidor">Distribuidor</div>
</div>
and the following code in javascript / jQuery:
$('.tipo-cadastro').click((e) => {
$('.tipo-cadastro').find('div').removeClass('active');
$(e.currentTarget).addClass('active');
});
My problem is that within my function e.currentTarget
corresponds to the parent element, that is, the element that has the click
event.
I know I could use the click event directly on each child element. But I would like to know if it is possible through the click event on the parent element to know which child element was clicked?