In the following source code, is it possible to create a JavaScript function which detects if the clickable element is in a specific node with a certain attribute.
Example:
<button data-type="mybutton">
<div class="mydiv">
<img src="">
</div>
</button>
The clickable elements could be the <img>
, <div>
, or <button>
tags, all included in the <button class='mybutton">
parent node. How can I create the condition in Javascript?
Something like this?
element.closest("button:data-type[mybutton]")
Thank you