A simple javascript log console...

作者:   發佈於:  

With jquery, it's easy to create a PRE element on-the-fly and use that for showing debugging messages. Pretty much like using alert(), only less annoying.

Setup:

$(function() \{
    $("<pre id='debug'></pre>").appendTo(document.body)
    .css(\{
        position: 'absolute', bottom: 0, right: 0,
        background: 'red', color: '#fff'
    \});
\});

Use:

$("#debug").text("Some debugging message here...");

Labels: debug, javascript, jquery