I just wonder if there is a way to use jQuery to log some variable values to Firebug console for debugging purpose?
3 Answers
jQuery is just a library for JavaScript, so you can just use the console.log() function:
console.log(myVar);
Comments
(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!");
1 Comment
OlliM
Actually, while it's stupid to involve jQuery in this in any way, a helper function which checks that console exists before writing to it is a good idea. You don't want your js code to stop working because there is no developer console (eg. in old IE).
console.log()getfirebug.com/logging