Today I will show you how to get a variable from your plugin. Lets say you want to know what a variable is that was passing to your plugin.

What we have here is the the plugin called myplugin with a function(callback)
1 2 3 4 5 6 7 8 9 10 11
$("#test-div").myplugin(
function(callback){
if(callback == 1){
alert("test variable equals 1");
}
});
The plugin
Ok, here is the plugin.
Now to send a variable back to our plugin call. We set a variable called testvariable. Then we create a function called callback with the variable testvariable.
1 2 3 4 5 6 7 8 9 10 11
(function($){
$.fn.myplugin = function(callback){
var testvariable=1;
callback(testvariable);
}
})(jQuery);
My name is Barrett and I am a Web Developer/Designer specializing in CSS, PHP, jQuery, Mysql and JavaScript.