跟随鼠标飘动的图片

    技术2024-10-31  31

    javascript代码:

    function initevent() { var pic = document.getElementById("pic"); if (!pic) { return; } document.onmousemove = function () { pic.style.display = ""; pic.style.top = window.event.clientY; pic.style.left = window.event.clientX; }; document.onmouseout = function () { pic.style.display = "none"; }; }

     

    网页内容:

    <body οnlοad="initevent()"> <div id="pic" style="position:absolute;display:none;"><img src="pvfhv.jpg" /></div> </body>

    最新回复(0)