Used to be able to perform a console.log on a jQuery object and Chrome would output the corresponding DOM element like the Elements Tab.
Now it does this:
console.log($('body'));
[<body>, context: #document, selector: "body"]
If you leave out the console.log, and type directly into the console you can get the old behavior:
$('body')
[<body>…</body>]
This is what I want! How do I get it back so I log jQuery objects programmtically and have them return live DOM objects like the elements Tab?
This should do it for you:
console.log($('body')[0]);
The reason being jQuery wraps elements in an array, so you need to access the actual element via an array index.
Or click the little triangle to the left to expand the output so that you can interact with the elements that are printed out.
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