4

I just wonder if there is a way to use jQuery to log some variable values to Firebug console for debugging purpose?

1
  • 2
    Why do you want to use jQuery? Just use console.log() getfirebug.com/logging Commented Feb 11, 2011 at 13:03

3 Answers 3

11

jQuery is just a library for JavaScript, so you can just use the console.log() function:

console.log(myVar);
Sign up to request clarification or add additional context in comments.

Comments

7
(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

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).
0

It's not jquery, just Firebug API:

console.log(2,4,6,8,"foo",bar)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.