Test if a selector matches a given element

后端 未结 7 1546
庸人自扰
庸人自扰 2020-11-27 05:58

Is there any way to test if a selector would match a given DOM Element? Preferably, without the use of an external library like Sizzle. This is for a library and I would li

相关标签:
7条回答
  • 2020-11-27 06:57

    For the benefit of those visiting this page after lo these many years, this functionality is now implemented in all modern browsers as element.matches without vendor prefix (except for ms for MS browsers other than Edge 15, and webkit for Android/KitKat). See http://caniuse.com/matchesselector.

    0 讨论(0)
提交回复
热议问题