The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Need to find a better way to log the essentials of a browser side HTML element using JavaScript object

Posted by jpluimers on 2023/12/04

The basic options for logging an HTML Element using JavaScript are for instance described in [Wayback/Archive] google chrome – How can I log an HTML element as a JavaScript object? – Stack Overflow (thanks [Wayback/Archive] Ben Flynn for asking and [Wayback/Archive] Mathias Bynens for answering)):

Use console.dir:
var element = document.documentElement; // or any other element
console.log(element); // logs the expandable <html>…</html>
console.dir(element); // logs the element’s properties and values

Both log all html or all properties even though often these are enough (most via [Wayback/Archive] Element – Web APIs | MDN):

Hopefully my post the day before yesterday about Destructuring assignment – JavaScript | MDN will help me figure out something to do this better.

It will be helpful when logging elements for instance after they are clicked on (see yesterday’s post javascript – Chrome debugging – break on next click event – Stack Overflow).

–jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.