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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

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

ios - I get the error Property '...' not found on object of type '...' -