Monday, November 05, 2007

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...");

0 意見:

My Bicycle Rides