Reputation: 36401
When I do
var el = document.querySelector('.some-class');
I get the plain HTML.
How then do I get access to the Javascript node element?
I can see it when I do dir(el)
in the console.
Upvotes: 0
Views: 1853
Reputation: 14053
Actually, document.querySelector() returns an element object, which implements the Element
interface which inherits from the Node interface.
Upvotes: 1
Reputation: 94
This is the dom itself. You can manipulate the element with only this. Why it is showing the HTML, it is just a common way that the console shows you. If you want to add a class for example, you can do.
var el = document.querySelector('.some-class');
el.classList.add('test')
This will work as it should. If you want to HTML of the element, you could also do:
el.outerHTML
Hope this helps you.
Upvotes: 1