10

I've been wondering about this for a while. Why does =$0 appears next to elements in the web inspector in Safari? I am using Safari 9.0.1

Here is a picture of what I'm talking about enter image description here

(larger):

enter image description here

Or if you prefer the version to read:

<div style="height: 100px; width: 2px; background-color: rgb(255,196,122); transform: rotate(-60deg); bottom: 10px; right: 80x;"> = $0

  • It is a variable you can use in the console. – John Keates Nov 29 '15 at 6:55
  • @JohnKeates Interesting. Thanks for sharing :) None of the other browsers have it and I saw it and wondered why it was there. – www139 Nov 29 '15 at 6:59
7

More than likely, you've used the Inspection Tool and have an element highlighted.

The $0–$4 variables contain the current and previous selected nodes from the Elements Tree Hierarchy.

source: https://webkit.org/blog/829/web-inspector-updates/

Chrome, Firefox, Opera, Safari - If you have an element currently selected in your "Elements" tab, you can use the reference $0 to call it within your code. For example, to see the elements' contents you would type $0.innerHTML. In Chrome and Safari, you can call the console from any of the other tabs by pressing "Escape" so you don't have to keep switching.

source: http://www.andismith.com/blog/2011/11/25-dev-tool-secrets/

1

$0 - $4 The $0, $1, $2, $3 and $4 commands work as a historical reference to the last five DOM elements inspected within the Elements panel or the last five JavaScript heap objects selected in the Profiles panel. $0 returns the most recently selected element or JavaScript object, $1 returns the second most recently selected one, and so on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .