<div class="parentDiv" >
<button class="close"
data-dismiss="modal"
style="..."
aria-label="Close"
onclick='$(this).closest(".parentDiv").remove()'
>
<span class="glyphicon glyphicon-remove-circle small"></span>
</button>
<div class="alert alert-danger">{{ errorMsg }}</div>
</div>
...
...
If I want to change the jQuery $(this) to pure JavaScript using querySelector, particularly for selecting the parent element with the "parentDiv" class name and removing it upon clicking on the element:
Note that Element.closest() should be used because there are multiple stacked Div elements with the "parentDiv" class name.
The goal is to target the parent element effectively without relying on the jQuery selector $(this).closest('.parentDiv').remove(). Is it feasible to achieve this without having prior knowledge of the current element's class or ID?