Skip to content

Instantly share code, notes, and snippets.

@geecu
Created October 1, 2010 14:53
Show Gist options
  • Save geecu/606308 to your computer and use it in GitHub Desktop.
Save geecu/606308 to your computer and use it in GitHub Desktop.
jquery.dbg.js
/**
* dbg jQuery plugin - http://jquery.5s.ro/
*
* Easy debug of your jQuery objects.
*
* @author Gunther Konig <gunther.s.konig@gmail.com>
*/
(function($)
{
$.dbg = function()
{
if (!("console" in window))
{
return this;
}
if(navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1)
{
console.log('<<<');
for (var i = 0, l = arguments.length; i < l; i++)
{
console.log(arguments[i]);
}
console.log('>>>');
}
else
{
console.log.apply(this, arguments);
}
return this;
}
$.fn.dbg = function()
{
var args = [];
//typeof arguments = object, we need an array
for (var i = 0; i < arguments.length; i++)
{
args[i] = arguments[i];
}
args[i] = this;
$.dbg.apply(this, args);
return this;
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment