Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, you can do it like this:</p> <pre><code>$('#someid').somePlugin('option', 'animation', 5000); </code></pre> <p>Additionally, you can change multiple options at once via:</p> <pre><code>$('#someid').somePlugin('option', {animation: 5000, otherOption: 'blah'}); </code></pre> <p>I should mention this only works for <em>certain</em> if you're using "official" jQuery plugins. A lot of plugin authors adhere to this design pattern, but not all do. Also, if you develop a plugin using the <a href="http://jqueryui.com/widget/" rel="nofollow">jQuery UI Widget Factory</a>, you get this functionality for free.</p> <hr> <p>EDIT: Since the OP is authoring his own plugin, we can show an example of how to facilitate this functionality with a custom plugin. Taken directly from the <a href="http://docs.jquery.com/Plugins/Authoring#Plugin_Methods" rel="nofollow">jQuery plugin authoring page</a>:</p> <pre><code>(function( $ ){ var methods = { init : function( options ) { //Extend options here with your //defaults and init your plugin }, option: function( key, value ){ options[key] = value; } }; $.fn.somePlugin = function( method ) { // Method calling logic if ( methods[method] ) { return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return methods.init.apply( this, arguments ); } else { //some error that method doesnt exist } }; })( jQuery ); $('div').somePlugin({someOption: true}); //..later $('div').somePlugin('option', 'someOption', false); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload