无法使用jquery为png图像设置淡出动画

Cannot animate png image to fade out using jquery

本文关键字:图像 设置 淡出 动画 png jquery      更新时间:2023-09-26

在我的html中我有:

<div id="testId">
    <img  src="img/Capture.PNG" alt="0" style=" background-color: red; margin-left:50px; "/>
</div>

在javascript中我有:

    $(function () {
        $("#testId").fadeOut(2000, function () {
            alert('animation complete');
        });
    });

我也试过:

    $(function () {
        $("#testId").fadeOut("slow", function () {
            alert('animation complete');
        });
    });

并且我的图像没有动画。它从100%可见变为0%。


编辑

它在任何浏览器中都不起作用。我试过谷歌chrome、safari和firefox。。。。这真的很奇怪。我希望我能给你看一段我的电脑的视频

我以前使用过jquery,不明白发生了什么!

我有两个问题:

1)我想在页面加载时立即为图像设置动画,所以如果你还记得的话:

$(function () {
    $("#testId").fadeOut("slow", function () {
        alert('animation complete');
    });
});
$(function(){}) executes that function when the dom is done but the image was not loaded yet!. I have to animate the image latter.

2)jquery库jquery-1.4.1.js不工作。我不得不去他们的网站下载最新版本。也许我无意中修改了文件。

编辑

我再次下载了jquery-1.4.1-vsdoc.js版本,以查看我是否意外修改了文件,而在该版本中,我的动画不起作用。。。。

查看下面的链接,它应该会对您有所帮助。

http://www.viget.com/inspire/jquery-ie-png-24-ie-black-background-issue-solved/