jeudi 5 janvier 2017

jQuery - 1 out of 3 div's but random

Heyy

I want to program a "Rock Paper Scissors" with a computer. Now, when I choose one of the 3 options, I want the computer to put in a random object - but how? I came up with something like this

jQuery ( when i click #rock, put in a random div from below)

$('#rock').on('click',function() {
           $('#putHere').text($("#rock" || "#paper" || "#scissors").text());
          });

HTML

 <div id="rock">rock</div>
 <div id="paper">paper</div>
 <div id="scissors">scissors</div>

May be misunderstandable but yeah.. I tried my best.. Thaks for the help though




Aucun commentaire:

Enregistrer un commentaire