How to call a jQuery plugin function outside the plugin?


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.

example

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

Instance the plugin and call the method −

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


Amit D
Amit D

e

Updated on: 12-Feb-2020

266 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements