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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:02:16+00:00 2026-05-28T16:02:16+00:00

I have an unordered list. When i click a shuffle button, i need: the

  • 0

I have an unordered list. When i click a shuffle button, i need:

  1. the items to fade out
  2. then randomise
  3. then fade back in.

All separate parts of my script work. The animated fade works on it’s own, and the shuffle works. The problem is when shuffle is in the script, that it skips straight to the shuffle, and stops all fade in or out.

Here is my script:

$('.vShuffle').click(function(){
    $('.list li').fadeOut(1000).shuffle().fadeIn(1000);                 
});

I have also tried this, which will fade out, then i assume it shuffles because it doesn’t do anything else after:

$('.vShuffle').click(function(){
    $('.list li').fadeOut(1000, function() {                    
        $('.list li').shuffle();
        $('.list li').fadeIn(1000);
    });
});

The shuffle script i’m using is from here, it works fine other than in my chain: http://mktgdept.com/jquery-shuffle

(function(d){d.fn.shuffle=function(c){c=[];return this.each(function(){c.push(d(this).clone(true))}).each(function(a,b){d(b).replaceWith(c[a=Math.floor(Math.random()*c.length)]);c.splice(a,1)})};d.shuffle=function(a){return d(a).shuffle()}})(jQuery);

Any help would be greatly apprecitated.

Thanks

  • 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-28T16:02:18+00:00Added an answer on May 28, 2026 at 4:02 pm

    Without doing some substantial debugging I can’t know exactly what’s going wrong, but I’m guessing the problem has something to do with the following:

    $('.list li').fadeOut(1000, function() {                    
        $('.list li').shuffle();
        $('.list li').fadeIn(1000);
    });
    

    Do you realize that the code inside the fadeOut callback (i.e. the shuffle() and fadeIn() function calls) is getting run once per every .list li element? In other words, if you have 10 elements that match the .list li selector, you’re actually shuffling and fading in all the .list li elements 10 times. That’s because .fadeOut will be called on every single matching .list li element, and therefore its callback will then be called.

    Instead, just call .fadeOut on the containing ul element, and then in the callback call .fadeIn on that containing element as well:

    $('.vShuffle').click(function(){
        $('ul').fadeOut(1000, function() {       
            $('li').shuffle();
            $('ul').fadeIn(1000);
        });
    });
    

    Here’s a working example: http://jsfiddle.net/mdur4/

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

Sidebar

Related Questions

I'm having some trouble figuring this out. I have an unordered list menu that
I have a simple unordered list with list items as menu item i created
I have an unordered list <ul> with list items <li> which I'd like to
I have an unordered list of 50 items. I want to show only 10
I have a dropdownlist with values. On a click of a button a unordered
I have an unordered list, with a couple list-items inside. Inside each of those
I have an unordered list of items with values appended as Data tags to
I have an unordered list with a bunch of list items. I am setting
I have an unordered list of items, something like this, shortened for brevity: <div
I have unordered list which has bulleted text within. I need to indent the

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.