i want to ask how to select the element properly.
When i click on the icon it gives me the i tag element but is nested inside an anchor tag. Which approach is correct:
// First Approach
if(e.target.parentElement.dataset.role === 'edit') {
// Do something
}
// Second Approach
if(e.target.dataset.role === 'edit') {
// Do something
}
<li>
<a href="#" class="secondary-content" data-role="edit"> <!-- Parent element -->
<i class="fa fa-pencil"></i> <!-- nested edit icon -->
</a>
</li>