views:

228

answers:

3

Hi,

I am looking at modifying a jQuery Plugin to cater for an additional requirement I need.

Sorry, not a programming question, but can you pass an array from javascript into a jQuery plugin, that will maintain all it's information or do I lose the array content between javascript and jQuery Plugin?

Thanks. TT.

+2  A: 

jQuery is written entirely in javascript. jQuery extensions (and indeed jQuery itself) are just normal functions. There's nothing special nor different about it, so to answer your question, yes you can pass arrays.

nickf
thanks for that and to the others.
tonsils
+1  A: 

Your array should have all the same data as it had when you passed it. jQuery is written in javascript and is merely a framework to make your life easier.

xenon
+1  A: 

Here's an example plugin that has an array as an argument.

// plugin definition
$.fn.myPlugin = function(arrArg) {
    // the plugin implementation code goes here
    // do something with arrArg, which is an array
};

Then to call the plugin with an array:

$('.class').myPlugin([1, 2, 3]);
thatismatt