English 中文(简体)
3. 连续体力运动
原标题:Continuous element movement with jQuery

我冒着 j的游戏,我希望我能自动行动,直到边界被击中。 我的行动守则是朝着正确方向制定的:

if (e.keyCode === 39 && (p1_left < 784)) {
    $( #p1 ).rotate(0);
    setInterval ( function() {
        $( #p1 ).animate( { left:  "+=16px", }, 50); }, 50);
}

我的这种举动与权利毫不相干,我没有说出自己如何制造停顿。

EDIT: 最新版的法典版 http://jsfiddle.net/BjCek/ >。

最佳回答

页: 1 因此, lo将永远持续下去:

while (p1_left <= 784) {
    pl_left+=16;
    $( #p1 ).css( left , p1_left); 
}

然而,这不会与你的品格的变动相适应,似乎只是跳跃到终点。 出于这一原因,无处不在。 你们可能想要的是,要么使用<条码>日落,来调换每一个职位或职位。 或者,您可使用<代码>animate,并附带下列功能:

function moveLeft(theID){
    $(theIE).animate({...},1000, function(){
       if(/* keep moving */){
           move_left(theID);
       }
    }
}
问题回答

你们需要的是不断呼吁的法典。 你的法典,正如你所写的那样,是一劳永逸的。 你们需要的是一套间隔期或设定时间,以启动您的法典,使其今后能够使用一定数量的零秒,每次都会增加财产。 实现这一目标的最容易的方法就是只使用这些方法的内部管理。

var $p1 = $( #p1 );
if (e.keyCode === 39 && (p1_left < 784)) {
  $p1.rotate(0);
  $p1.animate({  left  : 784 });
}

http://api.jquery.com/animate/“rel=“nofollow”http://api.jquery.com/animate/





相关问题
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.

热门标签