I need to get the ancestor or current element depending if it has a class.
Below is a jsfiddle of the a section of html. It is basically an a container div with inner elements. The container is repeated on the page. What I need to do is find out if the mouse element that the HTML dragenter event is fired on is contained within the container and if so set the class of the container.
How would I go about this?
Use
closestmethod which gets the first element that matches the selector, beginning at the current element and progressing up through the DOM tree.I think this will suit the best based on your requirement.
E.g: Consider this markup
JS