The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery Use Random Attribute

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #154908
    Steven Morgan

    I have this function, and I want to know how to use a different one every time a user comes to the page. For instance choose random transition values like slidein, slidedown, slideup, etc.

    speed: 650,
    transition: 'slideIn'

    Same way with a color element:

    $('element').css("background", "black");

    Get a random value for those. Do I have to create an array and have it select a random value? I’m not sure of the exact syntax on that

    var transitions = [
    var randomTransition = transitions[Math.floor(Math.random() * transitions.length)];
        speed: 650,
        transition: randomTransition
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.