简体   繁体   中英

Javascript/JQuery suddenly stops working in Chrome and Firefox, but still works in Safari

As the title states, I have a script that has just suddenly stopped working properly.

The script essentially replaces a jpg with an animated gif once hovered over said jpg.

Until today everything was working fine, but now the the animated gif doesn't play anymore for some unknown reason. With Firebug open, I can see that the script is still doing its job (jpg gets swapped for gif).

This problem is not occurring in Safari, but is occurring in Chrome and Firefox.

I'm guessing the problem is more to-do with the browsers and the gif rather than the script?

Here's the script:

    $(".image").hover(function(){
    $(this).attr("src", function(index, attr){
    return attr.replace(".jpg", ".gif");
    });
}, function(){
    $(this).attr("src", function(index, attr){
        return attr.replace(".gif", ".jpg");
    });
});

i)inspect element check it file path and CDN.

ii)View page source Don't load two different javascript library versions, only one is needed(ie) latest version.

iii)Check any conflict issue their.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM