I'm trying to write a new jQuery plugin.
base (this is not my plugin, just for better understanding):
(function($) {
$.fn.mySuperCoolPlugin = function(options) {
// Build main options before element iteration
var opts = $.extend({}, $.fn.mySuperCoolPlugin.defaults, options);
var editText= 'pre ' + opts.text + ' post';
return this.each(function() {
$(this).html(editText);
});
}
// Default settings
$.fn.mySuperCoolPlugin.defaults = {
text: 'hi'
}
})(jQuery);
Now after running my plugin I want to do some additional functions on it.
var plug = $('.text').mySuperCoolPlugin({text: 'running it'});
plug.runAnotherFunction('blabla');
// this for example should set the html to "pre running it post blabla"
plug.runAnotherFunction for example now should extend my previous text and add the text I entered.
Do you know what I mean? How to add extra functions to my plugin? I only see plugins you run once with some options.