$ in your browser's console

If you're in the console of Firebug, Chrome DevTools or in the new Firefox, you have some shortcuts available to you; these are called the command line API.

They're actually pretty damn consistent across browsers and documented here: http://getfirebug.com/wiki/index.php/Command_Line_API

$ and $$ are available and currently represent `document.getElementById` and `document.querySelectorAll` respectively. I actually wrote up the history of why this is: http://stackoverflow.com/a/10308917/89484

Since IDs are mostly out of style and $ is generally considered a querySelectorAll stand-in (thanks to jQuery).. we were thinking of making a small change.

Addy Osmani and I (Paul Irish) talked to Honza and RobCee (of Firebug and Firefox Developer Tools) and proposed the following change:

$ will now be equivalent to document.querySelector(). If you want your ID'd element, you can toss a # in there. It will return the first element that matches the selector (not a NodeList of all matches), so you can manipulate it directly instead of grabbing the [0].

We think this change would be awesome and we can have the Chrome DevTools, Firebug, and Firefox make the change more or less at the same time.


    This is a required question


    During discussing the above issue, we also noticed a small inconsistency. $$() returns an array in firebug and a NodeList in Firefox and Chrome DevTools. We could unify all of them to return an array, so its easy to do $$('div').forEach(... immediately.
    This is a required question
    This is a required question