问题
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