-3
var myArray = ['horizontal', 'vertical', 'fade'];    

I'm trying to make it MODE random.. Couldn't make it

  $(document).ready(function(){
  $('.bx').b({
  mode: 'fade'
  auto: true,
   });
  });
Styli
  • 1
  • 6

2 Answers2

0

You can just use Math.random() to generate an index to use for myArray, e.g.

var id = Math.floor(Math.random()*myArray.length);

...
mode: myArray[id],
...
asifrc
  • 5,781
  • 2
  • 18
  • 22
0

You just need a function to return a random element from an array:

function rand(arr) {
  return arr[Math.floor(Math.random()*arr.length)];
}

Putting it together...

$(document).ready(function(){
  $('.bx').b({
    mode: rand(myArray)
    auto: true,
  });
});
Nicole
  • 32,841
  • 11
  • 75
  • 101