I found it in code and don\'t know what\'s the point of using *.class
selector over .class
selector.
There's no point to it, whether in the jQuery (Sizzle) selector context or CSS selector context. Both *.class
and .class
are equivalent in terms of elements matched, and specificity.
The *
character is only significant when used by itself to refer to any element; it's implied the moment you use any other simple selector without a type selector. Even then, you will seldom, if ever, find yourself needing to hook events to or manipulate properties of every element on the DOM.
If you are going to use classes, pseudo-classes, IDs and so on, then there's no point having the universal selector there as the selected elements will be filtered accordingly anyway.
Furthermore, here's one shortcoming of using *
with other selectors, quoted from the jQuery documentation:
Caution: The all, or universal, selector is extremely slow, except when used by itself.
And here's what the Selectors spec says:
If a universal selector represented by * (i.e. without a namespace prefix) is not the only component of a sequence of simple selectors selectors or is immediately followed by a pseudo-element, then the * may be omitted and the universal selector's presence implied.
Examples:
*[hreflang|=en]
and[hreflang|=en]
are equivalent,*.warning
and.warning
are equivalent,*#myid
and#myid
are equivalent.