Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does jQuery support CSS4 selectors?

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

like image 874
Kamuran Sönecek Avatar asked Apr 05 '16 08:04

Kamuran Sönecek


People also ask

Are all CSS selectors compatible with jQuery?

Starting from jQuery 1.9, virtually all selectors in the level 3 standard are supported by Sizzle (its underlying selector library), with the following exceptions: jQuery cannot select any pseudo-elements as they are CSS-based abstractions of the document tree that can't be expressed through the DOM.

Is CSS4 supported?

CSS4 doesn't exist. In order to speed up the standardization of features supported by browsers, the CSS Working Group of the W3C split the CSS into smaller components called modules. And we must highlight that the CSS3 does not exist formally, is an extension of CSS 2.1.

Which CSS selectors can you not use in jQuery?

Given a list of elements and the task is to not select a particular class using JQuery. jQuery :not() Selector: This selector selects all elements except the specified element. Parameters: It contains single parameter selector which is required.

Does jQuery provide its own selectors?

jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors. All selectors in jQuery start with the dollar sign and parentheses: $().


1 Answers

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.

like image 106
BoltClock Avatar answered Sep 25 '22 05:09

BoltClock