๐พelem.isInside()
Element.prototype.isInside = function(selector){
return this.closest(selector) !== null
};
๐็ฏไพ๏ผ
function $(selector) {
return document.querySelector(selector)
}
document.body.isInside('html') // true
document.body.isInside('head') // false
$('body').isInside('html') // true
$('#p1').isInside('body') // true
Last updated
Was this helpful?