views:

190

answers:

2
  1. You have a console.log(o) in your code.
  2. Now in Firebug you can click on the object in the console, which takes you to the DOM inspector.
  3. I thought there was a way to then access from the console command line that object you just inspected with $0, but it doesn't seem to work.

Maybe something changed in Firebug, or I don't remember this correctly. Is there another way to do this in Firebug? If not, do you have workaround to suggest?

+1  A: 

From the HTML view or DOM view you can get an XPath for the element inspected. You can then paste the XPath in this code to get it as a var:

var $0 = new XPathEvaluator().evaluate('my-xpath', document, new XPathEvaluator().createNSResolver(document), 0, null).iterateNext();
Guss
@Guss Either this answers some other question, or I don't understand what you are saying :). I already have an object on the Firebug console. That object is not necessarily in the HTML. I want to be able to refer to it in the command line to try out code.
Alessandro Vernet
The object is visible in the console output, but its not in a variable that you can use. My code example puts the object in the variable $0 which you can use.
Guss
@Guss, this is not necessary anymore with Firebug 1.5, which now supports again the $0. Thanks for the answer!
Alessandro Vernet
+2  A: 

This works again in Firebug 1.5: you can access the last active element you looked at in the HTML tab from the console with $0. This is extremely convenient.

Alessandro Vernet