The Chrome developer tools stores your recent selection history in a special variable accessible in the console. Your most recent selection (in the elements inspector, or on the page with 'Inspect Element') is stored in
$0. Your second-most-recent is
$1, and so on, up through
Don't be fooled by the
$, this trick doesn't rely on jQuery or Zepto at all. Here's how to prove it:
Open a new tab and paste this in the address bar:
This creates a blank webpage with nothing more than a
body tag inside an
html tag. You won't see anything, but right click anywhere in the window and select 'Inspect Element'. Now go to the Console (click the tab, or pull it up quickly by hitting
esc) and type in
$0. You should see that it returned
<body></body>. No jQuery, no Zepto. Just magic.
Update: April 2016
Chrome is now making this even more clear, and less of a hidden trick. In the current Chrome Canary builds, you'll see a comment (
== $0) next to the selected element in the Elements inspector hinting at the global available to you in the Console.
What it doesn't hint at is the trailing $1–$4 globals which are also available. Check out the full details here in the Chrome DevTools API Reference.