Looks up a CSS selector string, returning the first element that matches. Equivalent to
document.querySelector()or calls the $ function in the page, if it exists.
Looks up a CSS selector string, returning a list of DOM nodes that match. This is a shortcut for
- The currently-inspected element in the page.
- Evaluate an Xpath expression and return an array of matching nodes.
Given an object, returns a list of the keys (or property names) on that object. This is a shortcut for
Given an object, returns a list of the values on that object; serves as a companion to
- Clears the console output area.
- Given an object, opens the object inspector for that object.
- Formats the specified value in a readable way; this is useful for dumping the contents of objects and arrays.
- Displays help text. Actually, in a delightful example of recursion, it will bring you to this page.
- Please refer to the Console API for more information about logging from content.
Example: Looking at the contents of a DOM node
Let's say you have a DOM node with the ID "title". In fact, this page you're reading right now has one, so you can open up the Web Console and try this right now.
Let's take a look at the contents of that node by using the
This automatically opens up the object inspector, showing you the contents of the DOM node that matches the CSS selector "#title", which is of course the element with ID "title".
Example: Dumping the contents of a DOM node
That's well and good if you happen to be sitting at the browser exhibiting some problem, but let's say you're debugging remotely for a user, and need a look at the contents of a node. You can have your user open up the Web Console and dump the contents of the node into the log, then copy and paste it into an email to you, using the
This spews out the contents of the node so you can take a look. Of course, this may be more useful with other objects than a DOM node, but you get the idea.