I am just messing around and am logging out a div that I have selected with standard javascript but that I have executed inside a jQuery document.ready(fn) block.
$(document).ready(function(){
console.log(document.getElementById( 'blah' ));
})
I'm really interested to know why sometimes I get...
<div id="blah"></div>
And other times I get...
Seems to log differently randomly.
The console. log() method outputs a message to the web console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.
In Chrome, navigate to Tools > Advanced > Error Console. The error console will open. Select JavaScript and Errors from the two drop downs. To find the error location, expand one of the errors.
This does appear to be random, at least in Chrome. If you want to force it one way or another in the Chrome console you can use console.dir and console.dirxml.
More examples of console commands in Chrome: https://developer.chrome.com/devtools/docs/console-api
Edit: dirxml also works in Internet Explorer 11 and later but not in Firefox though this shouldn't be an issue as Firefox outputs elements in xml format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With