Reputation: 758
I have a web page with the element:
<div id='myid'></div>
In chrome dev tools, when I type in the console
document.getElementById('myid')
returns a html element,
<div id='myid'></div>
is there an alternative method I can use to view it and it's properties as a JavaScript object instead rather than a html element?
I have seen this post, but all I want to do is get the element, not do any parsing and build something new and ideally in dev tools.
Upvotes: 2
Views: 8968
Reputation: 109
Would do something like using the Document Element interface to access the array of attributes / properties.
Upvotes: 0
Reputation: 32145
is there an alternative method I can use to view it and it's properties as a JavaScript object instead rather than a html element?
all I want to do is get the element, not do any parsing and build something new and ideally in dev tools
Yes if you are only interested in the dev tools (console), you can always use console.dir()
method, it's made for this:
console.dir(document.getElementById('myid'));
Displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.
Upvotes: 8