jQuery 翻转图像

Jae*_*Lee 1 jquery rollover

我有一个包含许多图像的页面,我想为它们使用翻转效果,即,当查看者将鼠标移到图像上时,图像源发生了变化。我已经尝试过 使用 jQuery Change the image source on rollover

但问题是我的图像位于不同的目录中。此外,图像文件名中有多个点。这与该网站是用 bigcommerce 构建的有关。

有解决方案吗?

Mat*_*ell 5

您可以在给出的示例中使用该函数,您只需要为两个图像传递正确的图像路径,而不仅仅是更改文件名。

$(function() {
    $("img")
        .mouseover(function() { 
            $(this).attr("src", "fullImageUrl/whateverOver.gif");
        })
        .mouseout(function() {
           $(this).attr("src", "fullImageUrl/whatever.gif");
        });
});
Run Code Online (Sandbox Code Playgroud)