How to get the active element in DevTools
Most modern browsers have a console shorthand you can use to get the element that’s currently active in the inspector. Once you’ve highlighted an element, you can refer to it by typing
$0 in the console.
In the image below, I have the
<h1> element highlighted in the inspector.
To access it in the console, I can use the
This gives you the same access to the element as if you had selected it using the
querySelector() method or similar 👍
If you have questions, feedback, or any other suggestions, please do email me. I'd love to hear from you!