If else statement in click event;
I want to get a random question from array, when the button firstly clicked the animation should be imlemented,all other times it just simply need to rewrite existing question with a new and random one. I thought the if/else statement should work here, but it doesn't. Here's my code:
var clicked = false;
var $feild=$('#questions');
var $screen=$('.container');
var $text=$()
$screen.hide();
$('.button').click(function(){
if(!clicked){
$feild.text(get_question);
$('.button').animate({
"top": "+=300"
},1000,function(){
$screen.fadeIn(2000);
clicked=true;
});
}else if(clicked){
$feild.empty();
$feild.append(get_question);
}
});