I’m interested in one vanilla JS function that will target the specific form that was submitted while having multiple forms with the same class name on the same page. Using IDs is not an option for each form.
Let’s say I have 10 forms like the following on some page:
<form class="add_to_cart">
<div class="btn btn__add_to_cart">Add To Cart</div>
<input type="hidden" id="some_product_id">
</form>
How can I grab with JS (no jQuery please) the specific form on which the div
element was clicked (I didn’t use button
element on purpose, i’m interested in the div
option)?
Will really appreciate your help.