📜  javascript onmouseover 更改图像 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:40.785000             🧑  作者: Mango

代码示例1
let img = document.querySelector('img');
    let start = img.src;
    let hover = img.getAttribute('data-hover'); //specified in img tag

    img.onmouseover = () => { img.src = hover; }
    img.onmouseout = () => { img.src = start; } //to revert back to start