Jquery disable click if hover too long -


i have jquery game can view here link text

the game starts entering number in text field. click play button.

after clicking play button set of square appear each rotating random numbers, click on square has number build score, miss 3 times , done.

i added game site, can view here link text

the problem i'm having site members keep cursor on 1 box , wait number appear in 1 box. ruins game. there way make can't click on same box more once in row. they'll have go click box before can come one.

here's complete script

var hitcount = 0,     misscount = 0;  function isnumeric(n) {     return !isnan(n); }  $("#getit").click(function() {     var hitcount = 0,         misscount = 0;     $('#hitcount').text(0);     $('#misscount').text(0);      $('#message').hide(100);     var li = [],         intervals = 0,         n = parseint($('#mynumber').val());      var intervalid = -1;     if (isnumeric(n)) {         intervalid = setinterval(function() {             li[intervals++ % li.length].text(math.random() > .1 ? math.floor(math.random() * (10 + n) + (n / 2)) : n).attr('class', '')    ;         }, <?php echo $time ?>);     }      $('#randomnumber').empty();      (var = 0; < 7; i++) {         li.push($('<li />').appendto('#randomnumber'));     }      $('#randomnumber').delegate("li", "click", function() {         var $this = $(this);          if (!$this.hasclass('clicked')) {             if (parseint($this.text(), 10) === n) {                 $this.addclass('correct');                 $('#hitcount').text(++hitcount);             } else {                 $this.addclass('wrong');                 $('#misscount').text(++misscount);             }              //new code if misscount > 3 stop game , save value             if(misscount>=<?php echo $limit ?>){                 clearinterval(intervalid);                 $('#randomnumber').undelegate("li", "click");                 // use ajax request save values                  $.ajax({                     type : 'post',                     url : 'fbhighscore_hwnd.php',                     datatype : 'json',                     data: {                         tgameid: $('#tgameid').val(),mynumber: $('#mynumber').val(),totalhits: hitcount                     },                     success : function(data){                         $('#waiting').hide(500);                         $('#message').removeclass().addclass((data.error === true) ? 'error' : 'success')                             .text(data.msg).show(500);                         if (data.error === true)                             $('#loginform').show(500);                         else                             $('#send').hide(500);                     },                     error : function(xmlhttprequest, textstatus, errorthrown) {                         $('#waiting').hide(500);                         $('#message').removeclass().addclass('error')                             .text('there error.').show(500);                         $('#loginform').show(500);                     }                 });              }         }          $this.addclass('clicked');     });      return false; }); 

what possibility of marking square 'inactive' once player has clicked on , re-activating after either mouseout or mouseover on 1 of squares?

something this:

$('.gamesquare').click(function() {     if(!$(this).hasclass('disabledsquare')) {          // game logic clicks here          $(this).addclass('disabledsquare');     } }  $('.gamesquare').mouseout(function() {     $(this).removeclass('disabledsquare'); } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -