Given the following JQuery plugin. Is it possible to expose the variable ‘elements’ to javascript external to the plugin? And if so, how is this done? For javascript external to this plugin, what would the syntax be to access ‘elements’?
(function($) {
$.fn.myPlugin = function() {
// I WANT TO EXPOSE THIS AS A 'PUBLIC' PROPERTY OF THIS PLUGIN
var elements = {};
return this;
};
})(jQuery);
$('.selector').myPlugin();
1 Answer