Logging to the Firebug console in jQuery

Firebug is a superb Firefox extension providing tons of tools in a very usable structure to aid you in HTML+CSS+JavaScript development. It also has good support for logging in your JavaScript code. Now a jQuery developer can take use of this to log any jQuery object to the console.

Saving the good stuff for later, here's the tiny extension that Dominic Mitchell came up with:
jQuery.fn.log = function (msg) {
  console.log("%s: %o", msg, this);
  return this;
};

After that one, you can log (even inside!) your jQuery expression:
$('#some_div').find('li.source > input:checkbox').log("sources to uncheck").removeAttr("checked");

I love jQuery and Firebug! Smile

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Perfect! Just what I was

Perfect! Just what I was looking for.
Eric