Home » Jquery » javascript and jquery flash animation

javascript and jquery flash animation

Posted by: admin February 22, 2020 Leave a comment

Questions:
var buttonColor = ["red", "blue", "green", "yellow"];

var gamepattern = [];

function nextSequence() {

  var randomNumber = Math.floor(Math.random() * 4);

  var randomChosenColor = buttonColor[randomNumber];

  gamepattern.push(randomChosenColor);

  $("#" + randomChosenColor).fadeIn(100).fadeOut(100).fadeIn(100);
}
div {
  height: 50px;
  width: 50px;
  display: inline-block
}

#blue {
  background: blue
}

#red {
  background: red
}

#green {
  background: green
}

#yellow {
  background: yellow
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="red"></div>
<div id="blue"></div><br/>
<div id="green"></div>
<div id="yellow"></div><br/>
<button onclick="nextSequence()">click</button>

This code failed to run, but ran on Mac not on my windows 10

How to&Answer: