parents

.parents() without jquery - or querySelectorAll for parents [duplicate]

*爱你&永不变心* 提交于 2019-11-26 14:08:44
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Check event.target.parentElement with matchesSelector js I have a dom object, I'd like to match its parents, all parents, against a selector, like querySelectAll() , but for parents instead of children. Similar to jQuery's .parents('selector') method, but I do NOT need any back-wards compatibility. Also, no libraries please. I will totes take a boolean return value. I CAN write this myself as a recursive