Answers for "javascript onmouseover change image"

2

javascript onmouseover change image

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
Posted by: Guest on October-24-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language