Last Updated: February 25, 2016
·
1.641K
· jlbruno

jquery.console.log.js

Originally from: https://gist.github.com/jlbruno/397528

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.
  • Example: $('.selector').find('children').clog().addClass('css');
  • You can pass it a msg to log out as well .clog('this should be children')