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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:17:00+00:00 2026-06-17T13:17:00+00:00

I am working on a jQuery plugin that hides all the elements within a

  • 0

I am working on a jQuery plugin that hides all the elements within a container and then shows them over a set interval using either fadeIn() or by jquery’s animate function.

So far I’ve managed to get all the elements into an array and I can print out the html in an alert if i do

$(children).each(function (index, val) {
     alert(this);
});

However, when i try to add the elements as html again to the document i get no luck.

I’ve tried

$(container).append(this);

and

$(container).appendChild(this);

but still no luck.

What i need ideally, is to be able to fadeIn() each element again and also add a css class to each element over a set interval.

(function($) {

$.fn.myPlugin = function (options) {

    // Set default options

    var defaults = {
        rate : '1000',
    }

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


    // Hide all elements within parent container
    $(this).children().hide();


    var container = $(this).selector;

    // Store children in loader variable
    var loader = $(this).children();


    // Put all elements into an array

    var children = [];

    $(loader).each(function(idx) {
        children.push(this.outerHTML); 
    });


    // Iterate over array and fadeIn elements;

    $(children).each(function (index, val) {


    });


};

})(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-17T13:17:02+00:00Added an answer on June 17, 2026 at 1:17 pm

    Somethink like this?: http://jsfiddle.net/zKpp2/1/

    (function ($) {
        $.fn.myPlugin = function (options) {
            // Set default options
            var defaults = $.extend({
                rate: 1000,
            }, options);
    
            // Hide all elements within parent container
            $(this).children().hide();
            var container = $(this).selector;
    
            // Store children in loader variable
            var loader = $(this).children(),
                length = loader.length;
    
            (function fadeLoop(index){
                if (index < length)
                    loader.eq(index).fadeIn(defaults.rate, function(){
                        $(this).addClass('foo'); // add class when done animating.
                        fadeLoop(index + 1);
                    });
            })(0);
        };
    })(jQuery);
    

    However, I would recommend something a bit more flexible: http://jsfiddle.net/zKpp2/3/

    (function ($) {
        $.fn.myPlugin = function (options) {
            // Set default options
            var def = $.extend({
                rate: 1000,
                onStepStart: $.noop,
                onStepFinish: $.noop,
                onFinish: $.noop
            }, options);
    
            // Hide all elements within parent container
            $(this).children().hide();
            var container = this;
    
            // Store children in loader variable
            var loader = $(this).children(),
                length = loader.length;
    
            (function fadeLoop(index) {
                if (index < length) {
                    def.onStepStart.apply(
                    loader.eq(index).fadeIn(def.rate, function () {
                        def.onStepFinish.apply(this);
                        fadeLoop(index + 1);
                    }).get());
                } else def.onFinish.apply(container.get());
            })(0);
    
            return container;
        };
    })(jQuery);
    

    Which you could use like this to accomplish the same thing you want (as well as many other things):

    $("#loader").myPlugin({
        rate: 1000,
        onStepStart: function(){
            $(this).addClass("foo");  // "this" just started fading in
        },
        onStepFinish: function(){
            $(this).removeClass("foo").addClass("bar");  // "this" finished fading in
        },
        onFinish: function(){
            $(this).css("background", "green");  // "this" is the original selector.
        }
    }).css("background", "red");  // chains properly
    

    Edit — The second version of the plugin doesn’t verify that def.onStepStart etc are actually functions, so it will break if you set them to something other than a function.

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

Sidebar

Related Questions

I am working on a plugin for jQuery that will essentially style certain elements.
I am working with a jQuery plugin that has the following snippet in it:
I'm working with a jQuery plugin that has this: var $el = $(this), $wrapper
First I am using the jQuery colorbox plugin that is working fine so far
I'm working on a plugin that allows popover panels in Jquery Mobile. A panel
I have been working on a jquery plugin that uses a HTML5 audio player
I am working on a jQuery plugin that people can include in their own
I'm working with a jquery plugin that requires me to identify certain buttons with
I'm working on a jQuery plugin that utilises JavaScript intervals. However, when the plugin
I'm working on very, very simple jQuery plugin that simply changes position of element

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.