Skip to content

Instantly share code, notes, and snippets.

@fransstudio2
Created April 30, 2020 15:31
Show Gist options
  • Save fransstudio2/5727107fbfa3e5eab1464d29d929d631 to your computer and use it in GitHub Desktop.
Save fransstudio2/5727107fbfa3e5eab1464d29d929d631 to your computer and use it in GitHub Desktop.
Simulate jQuery.parents(containerClass)
let containerClass = "containerClass";
let insideContainer = false;
let elem = event.target;
while (elem) {
if (elem.classList && elem.classList.contains(containerClass)) {
insideContainer = true;
break;
}
elem = elem.parentNode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment