Skip to content

Instantly share code, notes, and snippets.

@jlbruno
Created May 11, 2010 16:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlbruno/397528 to your computer and use it in GitHub Desktop.
Save jlbruno/397528 to your computer and use it in GitHub Desktop.
A jQuery 'plugin' to allow you to log to the console the current jQuery object
jQuery.fn.clog = function(msg) {
var txt = msg ? msg : "";
if (console && typeof console.log != "undefined") {
console.log('%o ', this, txt);
}
return this;
}
/*
* use .clog() in the middle of your chain to make sure you have the
* proper object before you continue. it will log the current jquery
* object to the console. ex:
* $('.selector').find('children').clog().addClass('css');
* you can pass it a msg to log out as well .clog('this should be children')
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment