0

I have just started trying out chrome developer tools. According to the chrome official website logging an element using console.log should show the html while console.dir should show the DOM on console. However on my system both show DOM. Even console.dirxml shows a DOM instead of html. Is this is a known issue? How can I change this behavior?

vjain27
  • 3,514
  • 9
  • 41
  • 60
  • 1
    I see expandable HTML representation when I use `console.log()`. Were you hoping for a single block of HTML? If so, use `element.outerHTML`. – cookie monster Jul 06 '14 at 15:48
  • 1
    if you need to see the html, you need to convert the element to a string http://stackoverflow.com/questions/1750815/get-the-string-representation-of-a-dom-node – philipp Jul 06 '14 at 17:59
  • 1
    Could you post a link to "the chrome official website" stating that "logging an element using console.log should show the html"? This is certainly an error, since the DOM node logging behavior hasn't changed for ages. – Alexander Pavlov Jul 07 '14 at 15:30

1 Answers1

1

If you wish to log the element's HTML, just use console.log(myElement.outerHTML).

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93