Does jQuery support CSS4 selectors?

烈酒焚心 提交于 2019-12-19 16:34:12

问题


Does jQuery or other JavaScript libraries support CSS4 selectors? Even browsers? How can I test them?


回答1:


The only level 4 selectors that jQuery supports at the moment are :has() and the extended version of :not() — and that's only because the spec took inspiration from jQuery itself, as jQuery had already implemented them years before the spec had its First Public Working Draft published in 2011.

I wouldn't expect jQuery to implement any of the other features until the spec has stabilized (i.e. reached at least CR). You'll notice that :has() doesn't appear in the 2013 WD that you link to. That's because the subject selector, that does appear in the 2013 WD, was dropped in favor of :has() only a little over a year ago.

So you can imagine why vendors are still holding back on implementing the spec. However, since at least one browser now partially implements Selectors 4, hopefully we won't have to wait much longer for other browsers to catch up.

You can easily test them by just using them and seeing if they return the elements you expect.




回答2:


css4 is still in draft. It is not adapted by all browsers. Whatever the browsers support css4 css declarations that will be automatically supported by jquery.



来源:https://stackoverflow.com/questions/36421224/does-jquery-support-css4-selectors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!