As far as I understand your question, you only want to check the HTML for debugging purposes, right?
document.querySelector
is a well tested function in browser's source code, so it cannot cause any problems at any time. So if you want to check that you're retrieving the correct element, you could simply use your browser's Developer Tools, the inspector: search for #text-area
in the Inspector, select it, and then it will be available as $0
in the Console. Then you can perform checks using this variables.
EDIT Ok so I got your question wrong. I tried using document.getElementById('something')
in my Chrome Developer Tools and the output is the HTML of the element. However, I suppose this behavior is not universal, so in order the ensure the HTML is written in the console, you can do:
var el = document.getElementById('text-area');
el && el.outerHTML;
Note that I am using the logical AND operator in order to make sure it is present before trying to access the outerHTML
property. This is for you not to get an error.