In Chrome, if one right-clicks a DOM element and selects "inspect element", then one is brought to the "Elements" tab of the debugger. In addition, the JavaScript variable $0
becomes populated with the "inspected" DOM element.
Given a DOM element, is there a way to have JavaScript force the browser to "inspect" it, so that the browser fills in the value for $0
natively, without doing the assignment ourselves?
As written in the documentation, the Chrome Web Developer supports Firebug's Command Line API. And one of the methods present there is inspect which does what you want.
Unfortunately, that is a Command Line API, which means that it's only valid in the console, at the command line, not from in-page scripts. There's no way to control the web developer tool from an in-page script, other than through the Console API which provides mostly logging facilities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With