Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New tip about storing a node as a variable
- Loading branch information
1 parent
5af24c9
commit 40d9496
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)! |