I learned something new today when developing in the Firefox Dev Tools console (although this applies to Chrome too)—something which was really useful and which I thought I’d share.
$$('selector') into the console (replacing selector as desired) and it’ll give you back all matching elements on the page.
So for example,
Similarly you can select a single element by instead using one dollar sign (
These seem to be console shortcuts for
document.querySelector() (in the case of
document.querySelectorAll() (in the case of
The other really cool thing is that the resultant
nodeList is returned as an array, so you could do e.g.
$$('li').forEach(…) or similar.
via @rem (Remy Sharp)