Repeat Javascript/jQuery until specific outcome -


I currently have the following code that appears in a noodle list and selects random objects. I want to make sure that the 'Li' line is not selected twice, or even better, do not choose to repeat, unless all of them are selected.

  var list = $ ('# headshot took: view'). ToArray (); Var elemlength = list.length; Var randomitem = list [Math.floor (* MathML) *;  

Full code:

  Function Soft Home PageAgentationHeadshots () { Var fullList = [1,2,3,4,5,6,7,8,9, 10]; Window.setInterval (function () {var random = fullList.slice (0) .sort (function () {return .5 - Math.random ();}); $ ('# headshots li'). Each (function ((= \ D + /, '')); Random = $ .grep (random, function) { Return value!) =) I;});}); var list = $ ('# headshots li: view'). ToArray (); var elemlength = list.length; var randomitem = list [Math.floor (mathematics. ) * Elemlength)]; $ (Random number) CSS ({'background-image': 'url ("' full redundant path + 'image / headshot / headshot-' + random [0] + '.jpg")'});}, 3000); }  

Added Bella:

remove random item Let's list variable, then it can not be selected again.
Take a look at this Bela where I use an interval to randomly select each item

  var list = $ ('# Headshots li: visible '); Var Loop = Set Interval (dot, 500); Function Chart () {if (list.length) {randomitem = list.splice (Math.floor (math.random (* * list.length), 1) $ (randomitem) .css ('background', '# ff0000' ); } And {clear interval (loop); }}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -