如何使用jQuery将值记录到Firebug控制台?

Ahm*_*med 3 debugging firefox jquery firebug

我只是想知道是否有办法使用jQuery将一些变量值记录到Firebug控制台以进行调试?

And*_*y E 12

jQuery只是一个JavaScript库,所以你可以使用这个console.log()函数:

console.log(myVar);
Run Code Online (Sandbox Code Playgroud)


jAn*_*ndy 8

(function($) {
    $.log = function() {
       if( 'console' in window )
            console.log.apply(null, arguments);
    };
}(jQuery));


$.log("hello world, I'm just kidding with this answer, please upvote it anyway!");
$.log("You should really just call console.log() directly");
$.log("Over and out!");
Run Code Online (Sandbox Code Playgroud)