javascript Check if an element is a descendant of another
const isDescendant = (child, parent) => parent.contains(child);
javascript Check if an element is a descendant of another
const isDescendant = (child, parent) => parent.contains(child);
js is element descendant
/* if you want to check deeply nested children*/
const isDescendant = (el, parentId) => {
let isChild = false
if (el.id === parentId) { //is this the element itself?
isChild = true
}
while (el = el.parentNode) {
if (el.id == parentId) {
isChild = true
}
}
return isChild
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us