4

Is it possible to make Google Chrome console to format output html. So if I will

console.log('<ul><li>1</li><li>2</li></ul>'); 

It will show real list instad of html markup

Adam Pietrasiak
  • 12,773
  • 9
  • 78
  • 91

3 Answers3

5

No, it does not seem possible. The Console API reference for Google Chrome mentions no such thing.

You can however create a debug div tag and add your contents to that:

<div id='debug'></div>

and

document.getElementById('debug').innerHTML = '<ul><li>1</li><li>2</li></ul>';
David Pärsson
  • 6,038
  • 2
  • 37
  • 52
1

A simple hack might be something like this:

console.html = function(data){
   var self = this;
   for(var i=0; i< arguments.length;i++){
      var wrapper= document.createElement('wrapper');
      wrapper.innerHTML = arguments[i];
      self.log(wrapper)
   }
}
Akhil Sekharan
  • 12,467
  • 7
  • 40
  • 57
0

Yes,

you can show a list using

console.log("hi",[1,2,3,4],"ho");

(The , are important, + will convert the array into String.

No, plain html is not possible.

enter image description here

Grim
  • 1,938
  • 10
  • 56
  • 123