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 6743883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:00:59+00:00 2026-05-26T12:00:59+00:00

Say, I have a jquery plugin with default options that can be overridden just

  • 0

Say, I have a jquery plugin with default options that can be overridden just like any plugin.

What I want to do is add multiple default options that can be called via the options or somewhere in the plugin “trigger”.
Question is.. How?

Jsfiddle that sort of explains it further:
http://jsfiddle.net/A7LMc/

How this plugin works is completely irrelevant to the question.



Essentially something like this:

    if ( option == 'b' ) { 
         var defaults = {
            width: '260',
            height: '120'
        }; 
    }
    else {
        var defaults = {
            width: '60',
            height: '10'
        };
    }

and then call it in the options something like this:

<script type="text/javascript">
$(document).ready(function() {
    $('.boxes').b({
    option: 'b',
    width: '500'
    });
}); 
</script>


To further elaborate:

This works but is not what I want:

http://jsfiddle.net/A7LMc/1/ ( in the js )

========

This doesn’t work and is more or less what I want:

http://jsfiddle.net/A7LMc/2/ (in the html )

..the reason why I said “more or less” is because.. well, it doesn’t work and I don’t really care how I can call it forth as long as it is in the plugin trigger code that is inside <script> tags and is simple.

  • 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-05-26T12:01:01+00:00Added an answer on May 26, 2026 at 12:01 pm

    Moved to the plugin: http://jsfiddle.net/A7LMc/3/

        if ( options.option == 'b' ) {
             var defaults = {
                width: '260',
                height: '120'
            };
        }
        else {
            var defaults = {
                width: '60',
                height: '10'
            };
        }
    

    And then:

    $('.boxes').b({
    option: "b",
    width: '500'
    });
    

    var optiondefault = "width:500";
    var optiona = { width: 260, height: 120, optiondefault  }
    var optionb = { width: 60, height: 10, optiondefault }
    
    $('.boxes').b({optiona});
    

    Otherwise why not do it inside the plugin?

    Or you could do it as an array like this….

    var options = {
                    a:{ width: '100', height:'100' },
                    b: { width: '100', height:'100' }
                };
    
    $('.boxes').b({options["a"]});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a jQuery plugin like $.abc = function() {}. Now I want
Say I have a web component that uses jQuery and I want to distribute
Lets say I have a jquery plugin called widget which can be used on
I DO NOT WANT TO CREATE A JQUERY PLUGIN Let's say I have something
Lets say I have the following jQuery plugin (this is just an example to
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have some kind of problem with jQuery selectors. Let's say i want to
Say that I have two html nodes like this: <div class='node a'>one</div> <input class='node
Say I have the following jQuery plugin: $.fn.myPlugin = function () { //plugin code
What's the best jQuery plugin (or any other javascript method) that allows me to

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.