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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:58:33+00:00 2026-06-09T10:58:33+00:00

I made default values for my function, but when I want to change them

  • 0

I made default values for my function, but when I want to change them by passing arguments values don’t change?

Here is an JsFiddle example

Here is my markup:

HTML:

<div class='container'>
    <img src='https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcRbQ6aMnp7uA2VHgEOY6oU24DcB-ZvoBF_puGTB6kq4c8DyMJr2'/>
    <img src='http://www.fullscreensavers.com/pics/nature02l.jpg' />
    <img src='http://www.fullscreensavers.com/pics/nature03l.jpg' />
</div>

CSS:

.container{
    position: relative;
    margin: 0 auto;
    width: 200px;
    height: 200px;
    margin-top: 50px;
}

.container img{
    position: absolute;
    top: 0;
    left:0;
    width: 100%;
    height: 100%;
    display: none;
}
​

Javascript:

var InfiniteRotator = {
    init: function(domEle, options) {
        options = {
            itemInterval : 5000,
            fadeTime : 2500,
            currentItem : 0
        };
        //count number of items
        var numberOfItems = $('img', domEle).length;
        //show first item
        $('img', domEle).eq(options.currentItem).fadeIn();
        //loop through the items
        var infiniteLoop = setInterval(function() {
            $('img', domEle).eq(options.currentItem).fadeOut(options.fadeTime);
            if (options.currentItem == numberOfItems - 1) {
                options.currentItem = 0;
            } else {
                options.currentItem++;
            }
            $('img', domEle).eq(options.currentItem).fadeIn(options.fadeTime);
        }, options.itemInterval);
    }
};

InfiniteRotator.init($(".container"),{currentItem: 1});​
  • 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-09T10:58:35+00:00Added an answer on June 9, 2026 at 10:58 am
    function(…, options) {
        options = {…};
    

    with this, you just overwrite the options argument. What you want is to extend the default options object with properties from the argument:

    function(…, customOptions) {
        var defaults = {…};
        var options = $.extend(defaults, customOptions);
        ...
    

    shorter, less variable confusion:

    function(…, options) {
        options = $.extend({…}, options);
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I get a bugfix I made on the default branch into a
I made a dll in c# but i need to export the functions. Is
I made a Web service in which I have a function to count some
In a previous question i made Dynamic dependent select menus i posted this example
i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { //
I have 30 buttons with nothing in default text value. What i want to
I am trying to get this Jquery count-up function to work but it's not
I made my first jQuery plugin attempt, but I have this problem/bug which I
I made a topic about the built-in python hash function: Old python hashing done
I've made this little plugin to show Twitter style alerts: jQuery.fn.myAlert = function (options)

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.