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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:12:52+00:00 2026-05-20T11:12:52+00:00

I decided that my previous question wasnt perhaps clear in both title and result,

  • 0

I decided that my previous question wasnt perhaps clear in both title and result, so I decided to ask the question like this…

I have 3 categories (A,B,C) and in these categories i have 3 items each. So category A)dog,cat,mouse B)apple,cherry,banana C)red,green,yellow.

I was wondering if its possible to group these items from the categories at random. So for example each time you click on the same button it would group: dog,apple,yellow or cat,cherry,green or mouse,apple,red , etc… and adds the class .grouped or whatever to that group. with only one possible group at a time with three items.

so i guess it would be like from start

class="dog"
class="cat"
class="mouse"
class="apple"
class="cherry"
class="banana"
class="red"
class="green"
class="yellow"

and then you click button & get:

class="dog grouped"
class="apple grouped"
class="yellow grouped"

click button again & get

class="cat grouped"
class="cherry grouped"
class="green grouped"

any thoughts or suggestions greatly appreciated

-david

  • 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-20T11:12:53+00:00Added an answer on May 20, 2026 at 11:12 am

    Its possible as you can see below. There are definitely more elegant ways to do this, but I figured this would be pretty straight forward to understand.

    http://jsfiddle.net/EN7HQ/1/

    JS

    var groupA = ["dog","cat","mouse"],
        groupB = ["apple", "cherry","bannana"],
        groupC = ["red","green","yellow"];
    
    $("#clickme").click(function(){
        $("#groups").children().remove();
        var itemA = groupA[Math.round(Math.random()*2)],
            itemB = groupB[Math.round(Math.random()*2)],
            itemC = groupC[Math.round(Math.random()*2)];
    
        $("#groups").append("<div class='" + itemA + " grouped'>" + itemA + "</div>"); 
        $("#groups").append("<div class='" + itemB + " grouped'>" + itemB + "</div>"); 
        $("#groups").append("<div class='" + itemC + " grouped'>" + itemC + "</div>"); 
    });
    

    Markup

    <div id="clickme">Click Me</div>
    <div id="groups">
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow up to a previous question that I had before about
I think I tried to ask for far too much in my previous question
I didn't want to make the title too long but this question specifically refers
I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to
I'm writing this question with reference to this one which I wrote yesterday. After
First of all (before this question get down voted): I am a developer developing
I'm using mostly jQuery (with asp.net), however I need to create a questionnaire. The
(More package/component install fun for me -- thanks everyone for all your help to
I've been tasked with setting up a wiki for our developers to share project
Please bear with me as I explain the problem, how I tried to solve

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.