DevTools Tips

Get the recently selected DOM nodes in the console

Categories: Supported by:

If you type $0 in the Console tool, in any browser, the currently selected DOM node is returned. This is very handy. To learn more, check Get the selected element in the console.

On top of this, in Edge and Chrome, the $1, $2, $3, and $4 shortcuts are also defined!

They can be used to access the recently selected DOM nodes:

Chrome DevTools, with the Elements and Console tools shown. 5 DOM nodes are selected, one after the other, and then the $0, $1, $2, $3, and $4 shortcuts are used in the Console, showing how they refer to the previously selected DOM nodes