javascript - How can i create order based click events -


i'm trying create web based game toddler involving counting. want make click 1 through 10 in order, cant click 3 until have correctly clicked 1 , 2 in order. pretty easy, i'm bit of noob when comes js. appreciated. thanks.

if you're new js, may want start learning jquery. find incredibly useful. it, this:

 <button value='1'> 1 </button>  <button value='2'> 2 </button>  <button value='3'> 3 </button> ...  <script>    var highest = 0;     $('button').click( function() {        if($(this).val() == highest+1)        {   highest = $(this).val();   alert("yay!");  }    }); </script> 

this code tell 'yay!' every time click next number.


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -