Use console.dir
:
var element = document.documentElement; // or any other element
console.log(element); // logs the expandable <html>…</html>
console.dir(element); // logs the element’s properties and values
If you’re inside the console already, you could simply type dir
instead of console.dir
:
dir(element); // logs the element’s properties and values
To simply list the different property names (without the values), you could use Object.keys
:
Object.keys(element); // logs the element’s property names
Even though there’s no public console.keys()
method, if you’re inside the console already, you could just enter:
keys(element); // logs the element’s property names
This won’t work outside the console window, though.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…