Does jQuery support CSS4 selectors?

前端 未结 2 869
野性不改
野性不改 2021-01-18 02:33

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

相关标签:
2条回答
  • 2021-01-18 03:28

    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.

    0 讨论(0)
  • 2021-01-18 03:38

    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.

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