This is Chrome's hint to tell you that if you type $0 on the console, it will be equivalent to that specific element.
Internally, Chrome maintains a stack, where $0 is the selected element, $1 is the element that was last selected, $2 would be the one that was selected before $1 and so on.
Here are some of its applications:
- Accessing DOM elements from console: $0
- Accessing their properties from console: $0.parentElement
- Updating their properties from console: $1.classList.add(...)
- Updating CSS elements from console: $0.styles.backgroundColor="aqua"
- Triggering CSS events from console: $0.click()
- And doing a lot more complex stuffs, like: $0.appendChild(document.createElement("div"))
Watch all of this in action:
Backing statement:
Yes, I agree there are better ways to perform these actions, but
this feature can come out handy in certain intricate scenarios, like when a DOM element needs to be clicked but it is not possible to do so from the UI because it is covered by other elements or, for some reason, is not visible on UI at that moment.