简体   繁体   English

DIVI 中的 Javascript:mouseenter 不起作用

[英]Javascript in DIVI : mouseenter does not work

I am creating a website for a client using Divi on WordPress.我正在使用 WordPress 上的 Divi 为客户创建一个网站。

I need to add some js code to create a mouseenter effet in order to change a logo to a Qr code.我需要添加一些 js 代码来创建mouseenter效果,以便将徽标更改为 Qr 代码。

There is the code :有代码:

    window.onload = function(){
        let wechatLogo = document.querySelector('#wechat img');
        wechatLogo.addEventListener('mouseenter', e => {
            wechatLogo.src = "/wp-content/uploads/2020/10/微信图片_20201017141208-1.jpg";
    });
    }

It does nothing on the front and there is not any errors.它在前面什么都不做,也没有任何错误。

I need probably your helps.我可能需要你的帮助。

Thanks a lot.非常感谢。

Try with wechatLogo.srcset尝试使用wechatLogo.srcset

window.onload = function(){
        let wechatLogo = document.querySelector('#wechat img');
        wechatLogo.addEventListener('mouseenter', e => {
            wechatLogo.srcset = "https://www.ateliersfrancochinois.com/wp-content/uploads/2020/10/微信图片_20201017141208-1.jpg";
    });
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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