Test if a selector matches a given element

后端 未结 7 1631
庸人自扰
庸人自扰 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:38

    Modern browsers can do it with the document.querySelectorAll function.

    http://www.w3.org/TR/selectors-api/

提交回复
热议问题