Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does mean == $0 in Chrome DevTools? [duplicate]

When you click on "Inspect an element" or on an element in the console you can see == $0 next to him.

What does this stand for ? What is the utility ?

You can type $0 in the console and it will output the element but how are you suppose to use it ?

like image 259
Baldráni Avatar asked Dec 10 '22 16:12

Baldráni


1 Answers

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:

Google

like image 131
Gideon Pyzer Avatar answered Jun 17 '23 02:06

Gideon Pyzer