Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9255313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:41:22+00:00 2026-06-18T11:41:22+00:00

For example I have jquery plugin and I call an init method with some

  • 0

For example I have jquery plugin and I call an init method with some atrributes like this:

jQuery(document).ready(function($) {
    $('#someid').somePlugin({
                           animation : 'fadeIn',
                           speed : '1000',
                           easing : 'swing'
                        });
});

Let’s pretend I have also html link on a page. Is it possible somehow to change attribute values of this plugin’s init function by clicking for example on html link?
So, by clicking on the link I want to change for example speed attribute without page refreshing. If this possible, what is the best way to implement this action?

Or maybe I should change something in my plugin’s code first.
Plugin’s code:

(function($) {
    $.fn.extend({
        somePlugin: function(options) {

            var defaults = {
                speed : 500,
                animation : 'fadeIn',
                easing : false
            }

            var options = $.extend(defaults, options);
            var speed = options.speed;
            var easing = options.easing;
            var animation = options.animation;

            return this.each(function() {
                var obj = $(this);
                //some action here 
            });
        }   
    });
})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:41:24+00:00Added an answer on June 18, 2026 at 11:41 am

    Yes, you can do it like this:

    $('#someid').somePlugin('option', 'animation', 5000);
    

    Additionally, you can change multiple options at once via:

    $('#someid').somePlugin('option', {animation: 5000, otherOption: 'blah'});
    

    I should mention this only works for certain 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 jQuery UI Widget Factory, you get this functionality for free.


    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 jQuery plugin authoring page:

    (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);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example I have this plugin code: jQuery.fn.keys = function(obj) { var keys =
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
I have the following jquery code: $(document).ready(function() { $(body[class*=page-calendar-practices] #content-header h1#title).after(<div id='athletics_practice-schedule'><div id='inner-title'><a href='www.example.com'
I use jQuery to attach some plugins in the $(document).ready() handler - for example,
jquery.ui.position is not taking the margin values when positioning items? I have this example,
I have a parseuri jQuery plugin method that affects the .val() of an input
I have a basic plugin written according the jQuery authoring guide . This plugin
I have build a little function which returns a jQuery plugin applied to a
I have used this example for a Jquery Live Dragable: jQuery Drag And Drop
I have problem when using jQuery plugin tablesorter and I can't call trigger twice.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.