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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:10:27+00:00 2026-05-27T03:10:27+00:00

I am writing a jQuery plugin. There are some default options and I can

  • 0

I am writing a jQuery plugin. There are some default options and I can change them on HTML, but how can I change an option if it consists of an array?

Here is the code in plugin:

(function($){    
    $.fn.extend({  
        aniTag: function(options) {     
            var defaults = {
                radius: 25,
                defaultradius: 0,
                enableTilt: true,
                tilt : 20,
                random : true, 
                randomMax : 25 ,
            };

            var colors = new Array('4AC7ED', 'FDC015', '9F78EC', 'F25C33');         

            var options = $.extend(defaults, options); 

            return this.each(function() {                
                var o = options;
                //some stuff
            });
        }
    });  
})(jQuery);

Here is the html usage:

<script type="text/javascript">
    $(document).ready(function() {
        $('.tags').aniTag({enableTilt: false});
    });
</script>

As you can see I can change enableTilt option. What I need to do is to change the values in the color array. Yes, I know I need to put that array in defaults var, but I don’t know how to do it.

  • 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-27T03:10:28+00:00Added an answer on May 27, 2026 at 3:10 am

    Add your array of colors to your defaults like so

    var defaults = {
        radius: 25,
        defaultradius: 0,
        enableTilt: true,
        tilt : 20,
        random : true, 
        randomMax : 25 ,
        colors: ['4AC7ED', 'FDC015', '9F78EC', 'F25C33']
    };
    

    Then you can overwrite them with

    $('.tags').aniTag({enableTilt: false, colors: ['ffffff', '000000']});
    

    Fiddle Demo: http://jsfiddle.net/Beufe/1/

    var defaults = {
        radius: 25,
        defaultradius: 0,
        enableTilt: true,
        tilt: 20,
        random: true,
        randomMax: 25,
        colors: ['4AC7ED', 'FDC015', '9F78EC', 'F25C33']
    };
    
    alert(defaults.colors.length);  // output: 4
    alert('Default Value colors[0] = ' + defaults.colors[0]);  // output: 4AC7ED
    
    var options = $.extend(defaults, {
        enableTilt: false,
        colors: ['ffffff', '000000']
    });
    
    alert(options.colors.length);  // Output: 2
    alert('New Value colors[0] = ' + options.colors[0]);  // output: ffffff
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a new jQuery plugin is there a straightforward way of checking that
I'm in the process of writing a jQuery plugin, and am getting into some
I am writing a jQuery plugin and I am at the optimization stage. I
I'm writing a jQuery plugin to render data retrieved from another domain in an
I'm playing around with writing a jQuery plugin that uses an attribute to define
I am writing my first jQuery plugin and I want to be able to
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I'm writing a semi-generic form plugin using jQuery in order to speed up the
I am trying to start writing some simple jQuery plugins and for my first
There's a very simple jquery plugin: autotextarea. I'd like to teach it one little

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.