Since $$
is just a wrapper for querySelectorAll
, you can pass any valid selectors.
"What type of functions can I do on a $$ object that I cannot really do with a jQuery ($) object?"
First, $$
isn't an object like jQuery. It is an object, but it's just a simple function object that is a wrapper (shortcut) for document.querySelectorAll
. It returns a NodeList
of the elements it found.
The only thing it supports that Sizzle doesn't specifically support, to my knowledge, is :nth-of-type
.
(Of course Sizzle defaults to qsa
when you give a valid selector, so you can pass nth-of-type
to the jQuery function in browsers that also support qsa
.)
With Sizzle, there are several selectors that are not supported by querySelectorAll
, so you can technically do more with jQuery/Sizzle.
Those include:
:eq()
:gt()
:lt()
:first
:last
:not()
(When you give it multiple selectors. Simple :not()
values are supported in qsa
.)
:animated
:input
:button
:checkbox
:even
:odd
:has()
:image
:password
:radio
:reset
:selected
:submit
:text
:visible
...to name a few several.
Keep in mind that Sizzle first tries to use querySelectorAll
. If you passed a proprietary selector, it then defaults to Sizzle's own engine.
Since qsa
is typically faster than Sizzle, it may be advisable to consider alternatives to the proprietary selectors listed above in order to improve performance.
Also note that Webkit
does not define $$
anywhere except for in the console. the $$
shortcut is not available in your scripts unless you make it available.
$
on a site without jQuery, it is a wrapper fordocument.getElementById()
. – Heterotopiareturn document.getElementById.apply(document, arguments)
and on a page with no javascript libraries you getreturn document.getElementById(id);
– Befog