Skip to content

Commit

Permalink
New tip about storing a node as a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
captainbrosset committed Oct 23, 2021
1 parent 5af24c9 commit 40d9496
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Binary file added src/assets/img/store-node-as-variable.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/tips/en/store-node-as-variable.md
@@ -0,0 +1,16 @@
---
title: Store a node as a variable to use it in the console
tags: ["html", "console", "browser:edge", "browser:firefox", "browser:chrome", "browser:safari"]
---
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](/tips/en/get-current-element-in-console).

![screenshot of firefox's "use in console" context menu option in the Inspector, and also showing the Console with a couple of tempN variables](/assets/img/store-node-as-variable.png)

Thank you [Austin Gil](https://austingil.com/) for sharing this tip on [Twitter](https://twitter.com/Stegosource/status/1451294683024355328)!

0 comments on commit 40d9496

Please sign in to comment.