小编asd*_*sdf的帖子

jQuery图像替换动画(模仿动画gif)

我有以下形式的JPGS序列:

Logo_1001.jpg
Logo_1002.jpg
Logo_1003.jpg
Logo_1004.jpg
Logo_1005.jpg
...
all the way to
Logo_1208.jpg
Run Code Online (Sandbox Code Playgroud)

我试图每秒(大致)改变图像的来源,以模仿动画gif,使用这些JPG.此动画在单击图像时开始.

这是我到目前为止使用的,虽然我确信它可以更好地编码.

此外,它现在还没有真正发挥作用; x

function StartAnimation() {
    var name = $('#logo').attr('src');
    var index = name.indexOf(".jpg");

    var int = name.slice(index-4,index);

    while(int<1208){
        int++;

        var newname=name.slice(0,index-4);
        newname=newname+int;
        name=newname+".jpg";

        $('#logo').attr('src',name).delay(500);
    }
}

$("#logo").click(function() {
    StartAnimation()
});
Run Code Online (Sandbox Code Playgroud)

思考?援助?

谢谢

jquery animation replace image

1
推荐指数
1
解决办法
4314
查看次数

标签 统计

animation ×1

image ×1

jquery ×1

replace ×1