Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- //four variables representing its button effects
- //button blue effect
- var blueButtonEffect = code here;
- var greenButtonEffect = code here;
- var redButtonEffect = code here;
- var yellowButtonEffect = code here;
- //to be used on the buttonEffects()/clickByItself()
- var arr = [blueButtonEffect, redButtonEffect, greenButtonEffect, yellowButtonEffect];
- let enabled = true;
- let times = 0;
- //makes button effects play itself randomly
- function clickByItself() {
- let random = Math.floor(Math.random() * arr.length);
- $(arr[random]).click();
- if (++times < 10) {
- setTimeout(function() { clickByItself(times); }, 1000);
- }
- }
- clickByItself();
- function turnOnTurnOff() {
- if (enabled == true) { //TRYING TO TURN ON/OFF THE FUNCTION ON BUTTON CLICK..
- $(startButton).on('click', clickByItself);
- }
- else(enabled != false) {
- $(startButton).on('click', clickByItself);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement