Jquery Randomizing within Categories

Posted by David Chase on Stack Overflow See other posts from Stack Overflow or by David Chase
Published on 2011-03-02T07:19:42Z Indexed on 2011/03/02 7:25 UTC
Read the original article Hit count: 514

Filed under:
|
|

Hi, so here is my question in a situation if you will. i have 6 items in div classes which correspond to 3 categories something like this
class ="boat"
class ="car"
class ="bike"
class ="blueboat"
class ="redcar"
class ="greenbike"

so is there a jquery/javascript approach with .addClass where when someone clicks on the button "Randomize" it addClass .mine to each one of the 3 categories ie blueboat.mine and redcar.mine and bike.mine but not boat or car or greenbike because they are in the same category?

or another situation rather than .addClass use a jquery/javascript so when "Randomize" is clicked to randomly show 3 out of 6 items one in each category of boat,car,bike and hide the rest blueboat,redcar,greenbike. in this situation all 6 items are on the page when document is ready but with the randomize only 3 are left one from each category.

please let me know if anyone has any ideas or needs further clarification any help is greatly appreciated.

thank you -david

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery