It's useful for debugging and playing around with elements using the Console API. If you select an element in the Elements panel, it gets added to a stack of index references. $0
refers to the last selected element, $1
is the one selected before that, and so on. It remembers the last five elements $0
- $4
.
This means you can quickly call functions, or change attributes and properties of these previously selected elements without needing to use a selector like document.getElementById('hplogo');
or $('#hplogo')
. Example below:
