English 中文(简体)
清楚的Interval()赢得了我轮值职能的起步。
原标题:ClearInterval() won t stop my rotate function

我用 j子罗特金gin,用90度的图像进行轮换,然后停止轮换。

我的问题是,即便在发出明确的Interval(Interval)(Interval)电话之后,它还是赢得了停止轮换;

$(document).ready(function() {
    var finalAngle;
    var intval = setInterval(function func() 
    {
      $("#myimg").rotate(1);
      if(typeof func.angle ==  undefined  )
      {
           func.angle = 0;
      }

      func.angle += 1;

      finalAngle = func.angle;

    }, 1);

    if(finalAngle == 90)
    {
      clearInterval(intval);
    }
});

基本上,所有Im公司(法定)都在计算角值,一旦打到90个点,就称为明显的间隔功能。 我不得不采用另一种变数来储存这一计数,以便我能够超出规定的间隔期职能。

最佳回答

简便:set Interval, 然后评价finalAngle/code> 的条件,在缩略后,请您轮流担任职务。 因此,clearIntervalfinalAngle为90时从未上过。

该法典应适用于:

$(document).ready(function() {

    var intval = setInterval(function func() 
    {
      $("#myimg").rotate(1);
      if(typeof func.angle ==  undefined  )
      {
           func.angle = 0;
      }

      func.angle += 1;

      if (func.angle == 90)
      {
        clearInterval(intval);
      }    
    }, 1);  
});
问题回答

<代码>if说明一经执行。 情况如何?

$(document).ready(function() {
    var finalAngle;
    var intval = setInterval(function func() 
    {
      $("#myimg").rotate(1);
      if(typeof func.angle ==  undefined  )
      {
           func.angle = 0;
      }

      func.angle += 1;
      finalAngle = func.angle;
      if(finalAngle == 90)
      {
          clearInterval(intval);
      }


    }, 1);


});

尽管我看不出你为什么会放弃......。

$(document).ready(function() {
    var finalAngle=0;
    var intval = setInterval(function func() 
    {
      $("#myimg").rotate(1);

      finalAngle++;

      if(finalAngle == 90)
      {
          clearInterval(intval);
      }


    }, 1);


});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签