简体   繁体   中英

Does jQuery support CSS4 selectors?

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

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 (ie 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM