为了浏览器游戏的目的,我只想在图像正在动画时将图像 src 更改为动画 gif。
$(the_image_selector).animate({marginLeft: amount}, time);
我该怎么做?
我的想法是在调用animate之前把图片转成gif,然后用animate的回调把图片改回来。会成功吗?
最佳答案
是的,我确实认为你的策略会奏效,例如
var image = $(the_image_selector);
image.attr('src', 'url to show while animated');
image.animate({marginLeft: amount}, time, function(){
image.attr('src', 'normal url');
});
关于javascript - 仅在为其 margin-left 设置动画时更改图像 Src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23129374/