Reputation: 23475
Using only pure javascript without jquery, how do you display all the possible methods and properties of an element object? Say I have the body object - document.getElementByTagName('body')[0]
How do I list out all the possible methods I can use? And what properties it has? I know I can use .click() and .setAttribute but what else is there?
How would I find out using the Chrome console?
Upvotes: 1
Views: 62
Reputation: 66334
Rather than using console.log
, I'd suggest console.dir
console.dir(myObj);
dir
will show your Object's properties even if you pass a Node, rather than showing the tree-view in the console, which will happen with log
if it recognises the Object as a Node.
Upvotes: 4
Reputation: 7181
Somewhere in your code you want to log the object to the console:
console.log(MyObjectInstance);
Then when you open chrome developer tools you can go to 'console' and view your object. There should be a little arrow next to the logged object that you can click to view all of its methods and attributes.
Upvotes: 0