LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

Heads or Tails?

Click the button to decide!












JS
var coin = ['Heads!', 'Tails!'];

function flip(){
  var coinFlip = coin[Math.floor(Math.random() * 2)];
  document.getElementById('results').innerHTML = coinFlip;
}

function reset(){
	document.getElementById('results').innerHTML = 'Flip again?';
}

$(document).ready(function(){
  // when page loads hide reset button, show flip button   
        $("#reset").hide();
        $("#flipACoin").show();
	// on flip button click hide it and show reset button
       $("#flipACoin").click(function(){
             $("#flipACoin").hide();
				 		 $("#info").hide();
             $("#reset").show();
        });
	// on reset button click hide it and show flip button
      $("#reset").click(function(){
              $("#reset").hide();
             $("#flipACoin").show();
       });
});


document.getElementById('flipACoin').onclick = flip;  
document.getElementById('reset').onclick = reset;
Term
Sat, 04/14/2018 - 20:47

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv