Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
catalin560
@catalin560
I don't know how to explain it any more simpler
Abhishek Saini
@sainiabhi
can we go point by point:
  1. when you click start, the green should turn to white
then?
catalin560
@catalin560
after clicking start green will flash white > JS will wait for user to press the green button
then execute the next function
Abhishek Saini
@sainiabhi
ok
catalin560
@catalin560
so instead of changing the bg color I will use animate
anyway
how do I tell JS to WAIT for an event?
Abhishek Saini
@sainiabhi
see to run some function after some time use setTimeout function
catalin560
@catalin560
ok so what setTimeout does is it executes a function after a time period
that isn't waiting for a event...
@sainiabhi
Abhishek Saini
@sainiabhi

@catalin560 yes do one thing

```

$('.start').click(function(){
  setTimeout(function(){
  alert("In set time out function");
   },1000);
});
so you can see after 1 second alert will run
1000ms = 1s
catalin560
@catalin560
@sainiabhi yes I know that... after 1 second an alert will pop up
thats not what I'm looking for...
oh I think I got it!
Abhishek Saini
@sainiabhi
@catalin560 great :P
catalin560
@catalin560
can a button get a active property after being clicked?
@sainiabhi ?
Abhishek Saini
@sainiabhi
by active you mean what? @catalin560 are you trying to disable the button first?
catalin560
@catalin560
by active I mean its being clicked
Abhishek Saini
@sainiabhi
every button is supposed to be clicked :P
catalin560
@catalin560
@sainiabhi other question then... can it gain a "certain" property after being clicked?
Abhishek Saini
@sainiabhi
@catalin560 yes it can
@catalin560
$('button').attr('active', 'vfsdd');
catalin560
@catalin560
@sainiabhi nice! finally something I can use!
Abhishek Saini
@sainiabhi
@catalin560 keep going
:)
catalin560
@catalin560
@sainiabhi another problem
$('.start').click(function(){
        $(".btn-green").animate({bottom: "+=10px"});
    setTimeout(function(){
       $(".btn-green").animate({bottom: "0"});
    },200);
});
why wont it animate?
Abhishek Saini
@sainiabhi
@catalin560 let me check will let you know
Abhishek Saini
@sainiabhi
@catalin560 it's because you should give .btn-green{position: absolute;}
similarly set position:absolute for other buttons too
catalin560
@catalin560
@sainiabhi I found a way to animate colors for each button wanna give it another try and tell me what you think? :)
@catalin560 press start then press each button that flashes white
Abhishek Saini
@sainiabhi
@catalin560 sure
catalin560
@catalin560
@sainiabhi hey you still there?
Abhishek Saini
@sainiabhi
@catalin560 yeah tell me?
catalin560
@catalin560
@sainiabhi I have a question
I've made this basic, very rudimentary Simon Says app
now what I want to do is make it so that it happens at random
can I declare those click()functions as variables and make them run thru a rand() function or something like that?
like
var colors=[green,red,yellow,blue]
var green=function(...)
etc
call rand(colors)???
Abhishek Saini
@sainiabhi
you want to randomly pick colors?
catalin560
@catalin560
@sainiabhi yes
Abhishek Saini
@sainiabhi
var colors = [green,red,yellow,blue];  //array
var num = Math.ceil(Math.random() * 3);  // as we have 4 items in the array, we will throw random numbers to select a number randomly 

var randomColor = colors[num];  //It will take colors randomaly from array colors