If you want to use a DOM node from the page in the console:
- Right-click the node in the Elements (or Inspector in Firefox).
- Click on Store as global variable (or Use in Console in Firefox).
The Console opens up, pre-filled with a new variable name (something like temp1
) which you can use to refer to the node any time you want.
Note that if you only want to refer to the currently selected node (and not create a new variable), you can also use $0
in the console.
Thank you Austin Gil for sharing this tip on Twitter!