English 中文(简体)
JS/jerylay loop to seek result (delay(不工作))
原标题:JS/jQuery delay loop to get desire result (delay() not working)

I m 试图通过将图像的背景定位在 lo中形成装饰:

$( #LoginButton ).click(function () {

    var i = 1, h = 0, top;

    for (i = 0; i <= 12; i++) {
        h = i * 40;
        top = h +  px ;
        $( #ajaxLoading ).css( background-position ,  0 -  + top).delay(800);
    }

});

The problem here is that it runs to fast so I don t se the animation of the moving background. So I added jquerys delay(), but:

延误(800)没有奏效,因为延迟()只进行 j蒸效应,cs()不是其中之一。

如何拖延这一 lo?

最佳回答
问题回答

Chrome, Safari and IE3+ should support background-position-y, so if you re targeting these specific browser, using jquery you could just make a timed animation() on backgroundPositionY property - http://snook.ca/archives/html_and_css/background-position-x-y (On Firefox the effect won t work)

为了做到这一点,你可以使用定时和明确的时间。

IE:

var GLOBAL_i = 0;

function doAnimation() {

    var h = GLOBAL_i * 40;
    var top = h +  px ;
    $( #ajaxLoading ).css( background-position ,  0 -  + top);

    if (GLOBAL_i < 12) {
        GLOBAL_i++;

        t=setTimeout(doAnimation, 800);
    }
}

$( #LoginButton ).click(function () {

    doAnimation()

});




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

热门标签