jquery
  • setinterval
  • onmouseout
  • 2011-03-30 1 views -2 likes 
    -2

    하여 setInterval은 여기mouseout jquery에서 setInterval하는 방법? 로 마우스에

    <script type="text/javascript"> 
    $(document).ready(function() { 
    $("#time").load("ajaxTime.php"); 
    
    var refreshId = setInterval(function() { 
    $("#time").load('ajaxTime.php?randval='+ Math.random()); 
    }, 1000); 
    $('#stop').mouseover(function(){ 
        clearInterval(refreshId); 
    }); 
        $('#stop').mouseout(function(){ 
        setInterval(refrashID, 1000); 
    }); 
    }); 
    
        </script> 
         <center> 
          <div id="stop" style="width:100px; height: 100px; border: 1px solid #000;"> 
           <div id="time"></div> 
          </div> 
         </center> 
    
    +0

    왜 1 인의 담당자에게 투표 하시겠습니까? 투표를 닫으세요 ... –

    답변

    0

    먼저 내 코드 제발 일이 어떤 날 도울 수 해달라고, 당신은 refrashID 대신 refreshId을 썼다. 그러나 당신이 변수로 원하는 기능을 할당하여 재사용 할 수 있도록해야합니다.

    var $interval_function = function() { $("#time").load('ajaxTime.php?randval='+ Math.random()); }; 
    
    // then when you set the interval: 
    refreshId = setInterval($interval_function, 1000); 
    
    // clear the interval: 
    clearInterval(refreshId) 
    
    // and you have to store the new result from setInterval if you run it again: 
    refreshId = setInterval($interval_function, 1000); 
    
    +0

    대단히 감사합니다. – bosko

    관련 문제