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 items on the page.
So for example,
Similarly you can select a single element by instead using just one dollar (
These basically 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.