I m trying to make a nice representation of the console.log onto the page itself. I have the following:
window.PRINT = function() {
if(this.console) {
console.log( Array.prototype.slice.call(arguments) );
}
var X = $( #PRINT );
if (!X) {
$( body ).append( <p id="PRINT"></p> );
X = $( #PRINT );
}
$.each(arguments, function(Index, Value) {
X.append( <p> + JSON.stringify(Value) + </p> );
});
};
问题在于我何时使用它。
$( input ).change(function(myEvent) {
PRINT(myEvent,this);
});
It doesn t really do a very good job of printing out the objects and their contents. I wonder if there s a json formatter somewhere. I m not talking about a Firefox plugin, I mean: one that accepts json coming in and outputs a nice html representation of it, perhaps.