Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to call a jQuery plugin function outside the plugin?

I am working on jQuery and its plugins. I am quite confused with how to use jQuery plugins. How can I call a jQuery plugin function outside the plugin?


1 Answer
Amit D

jQuery is a JavaScript library introduced to make development with JavaScript easier. It reduces the development time. Let us see how to call a jQuery plugin function outside the plugin.

For calling, wrap the jQuery method for returning the instance of the constructor. Call prototype methods on it.

For example,

$.fn.myFunction = function(config){
    return new myFunction (config);
};

Instance the plugin and call the method:

var plugin = $('#someSelector').myFunction();
plugin.setToken(column);
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.