Welcome to my jQuery Debugger Plugin Demo. This is the first real plugin I've ever made for jQuery. My main site is at www.andygroff.com. Feel free to get in contact with me in the comments there, or email me if you have questions/comments or if you need help.
First things first, you can download the jQuery Debugging Plugin by clicking that link.
Basically, this plugin is just one function, attached to the global jQuery object, $ , which is named debug() , and which is capable of displaying the value of a variable. It handles objects and things much better than a simple alert. The variable will be displayed in a div with a high z-index so that it hopefully appears above the other elements on the page.
Normally, you will just call it with one parameter, which is the variable you would like to view, sort of like this: $.debug(myMysteriousVariable); .
Alternatively, you can pass in a second parameter, which is an options object, which just defines a few options, sort of like this:
Basically, the only important option here is the one called recursive, which is a boolean telling the plugin if it should recursively loop through an objects properties or not. Other than that one, you'll probably only care about the divCss option which accepts standard CSS properties. Here are the default values for all of the options:
One common task, expecially when doing Object Oriented Javascript, is that you want to see the value of an object with multiple nested layers. This debugging plugin handles this task pretty well. Try it out: Debug the object shown below
Just like the Object Example, but this time we're passing an array.
Debug the Array shown below
Just like the other Examples, except now were veiwing and html element.
HTML Elements are different though, and its worth noting. Because using the recursive option was producing an infinite loop sometimes, I disabled it for html elements. Instead of looping through all of the element's properties, it only displays a few helpful ones. Any suggestions for making this part better are quite welcome.
Debug the "footer" div from this page, also shown below
Here, I'm just gonna show you how the plug-in handles a few other data types.
Lets pass a function to our plug-in.
Debug a Function
Lets pass a string to our plug-in.
Debug a String
Lets pass a number to our plug-in.
Debug a Number
Lets pass a boolean to our plug-in.
Debug a Boolean
I just thought it might be fun to pass in the jQuery object and see what happens :-)
Debug jQuery