Posted By

garside on 12/09/08


Tagged

jquery log firebug


Versions (?)

Who likes this?

15 people have marked this snippet as a favorite

kevcow
not_skeletor
krunkosaurus
lfatr
francesL
troynt
umang_nine
spraitas
HubertGaulin
sionnnn
vali29
joe-bbb
anobre
rijnbeek
Jarek


jQuery to Firebug Logging


 / Published in: jQuery
 

URL: http://getfirebug.com/logging.html

A simple but powerful interface for allowing firebug access functions in the jQuery chain.

See the link above to check out the functions it accepts.

  1. $.enableConsole = false;
  2. $.fn.console = $.console = function(method){
  3. if (window.console && console[method] && $.enableConsole)
  4. console[method].apply(this, [].splice.call(arguments,1))
  5. return this;
  6. }
  7.  
  8. // When debugging code, be sure to set:
  9. $.enableConsole = true; // Or none of your lines will reach the console
  10.  
  11. // You can call any firebug functions through either the direct jQuery object, or in a chain:
  12. $.console('debug', 'This is some %s text', 'debugging');
  13.  
  14. // The best part is the ability to use the firebug console chain easily:
  15. var color = '#FFF';
  16. $('#someElement').css('backgroundColor', color).console('log', 'Changing the background color to "%s"', color);
  17.  
  18. // And the access to the other functions of the firebug console, like time/timeEnd
  19. $('#someElement').console('time', 'timing foo').animate({...}).console('timeEnd', 'timing foo');

Report this snippet  

You need to login to post a comment.