Passing arrays to jQuery plugin

I am considering modifying the jQuery plugin to meet the additional requirements that I need.

Sorry, this is not a programming issue, but can you pass the array from javascript to the jQuery plugin that will support all its information or will I lose the contents of the array between javascript and the jQuery plugin?

Thanks. TT.

+3
source share
3 answers

jQuery is written entirely in javascript. The jQuery extensions (and indeed jQuery) are just normal functions. This is nothing special and no different, so to answer your question, yes, you can pass arrays.

+3
source

, .

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

:

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

Your array should contain all the same data as during the transfer. jQuery is written in javascript and is just the foundation to make your life easier.

+1
source

Source: https://habr.com/ru/post/1708979/


All Articles