Elements inspector
suggest changeIn Chrome’s Elements tab or Firefox’s Inspector, the “select an element” button, then a click on an element, highlights it and assigns it to $0 in the console.
The inspector can be used in a variety of ways, for example:
- You can check if your JS is manipulating DOM the way you expect it to,
- You can more easily debug your CSS, when seeing which rules affect the element
(Styles tab in Chrome)
- You can play around with CSS and HTML without reloading the page.
Also, Chrome remembers last 5 selections in the Elements tab. $0 is the current selection, while $1 is the previous selection. You can go up to $4. That way you can easily debug multiple nodes without constantly switching selection to them.
$0 through $4 are console helpers, not JavaScript variables in the page. See Chrome’s console utilities.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents