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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:19:29+00:00 2026-05-25T22:19:29+00:00

I got a table with three columns: 1 A A 2 B B 3

  • 0

I got a table with three columns:

1 A A
2 B B
3 C C
4 D D

What I want to do is to shuffle the table rows but only the second and third column, like the example below

1 C C
2 A A
3 D D
4 B B

I found a nifty plugin wich lets the table rows to be shuffled
http://www.yelotofu.com/2008/08/jquery-shuffle-plugin/

but I want to keep the first column in it’s default order.
Either I will reorder the first column after shuffling or I just shuffle
the second and third column. Either way can somebody help me out with this?

  • 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-25T22:19:30+00:00Added an answer on May 25, 2026 at 10:19 pm

    Fiddle: http://jsfiddle.net/tGY3g/

    Here you go:

    (function($){
        //Shuffle all rows, while keeping the first column
        //Requires: Shuffle
     $.fn.shuffleRows = function(){
         return this.each(function(){
            var main = $(/table/i.test(this.tagName) ? this.tBodies[0] : this);
            var firstElem = [], counter=0;
            main.children().each(function(){
                 firstElem.push(this.firstChild);
            });
            main.shuffle();
            main.children().each(function(){
               this.insertBefore(firstElem[counter++], this.firstChild);
            });
         });
       }
      /* Shuffle is required */
      $.fn.shuffle = function() {
        return this.each(function(){
          var items = $(this).children();
          return (items.length)
            ? $(this).html($.shuffle(items))
            : this;
        });
      }
    
      $.shuffle = function(arr) {
        for(
          var j, x, i = arr.length; i;
          j = parseInt(Math.random() * i),
          x = arr[--i], arr[i] = arr[j], arr[j] = x
        );
        return arr;
      }
    })(jQuery)
    

    Usage

    $("table").shuffleRows()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a database table with at least three rows in it. From php,
I've got a database table called servers with three columns 'id', 'name', and 'votes'.
I have a table with three NCLOB columns. For each NCLOB I want a
I've got a table with three columns, obj1, obj2 (both varchars) and the distance
I got a table where in got allocated space of 3gig but have no
I've got a table of URLs and I don't want any duplicate URLs. How
I got this example from one StackOverflow question that was asked but I couldn't
I need some help joining two table. I've got: my_type_table , which has columns:
I have a table with about 1000 records and 2000 columns. What I want
So I've got a MySQL table with the following columns: PROPERTY_ID AGENT_ID STATUS SALE_DATE

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.