0

onmousemove in js

Hi, I want the mouse to be moved on each of the photos when it is placed on it. The photos are opened and displayed with a larger size and exactly where the mouse is located. Where is the problem <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style> img { width: 300px; height: 300px; } </style> <script> function mouseneter(e) { if (document.getElementById("orgininalphoto")) removephoto(); var img = e.srcElement; var orgimg = document.createElement("img"); orgimg.src = img.src orgimg.style.width = "400px"; orgimg.style.height = "400px"; orgimg.style.zIndex = "999"; orgimg.style.position = "absolute"; orgimg.style.left = e.clientX; orgimg.style.top = e.clientY; orgimg.id = "orgininalphoto" document.body.appendChild(orgimg); } function removephoto() { document.body.removeChild(document.getElementById("orgininalphoto")); } </script> </head> <body> <img src="img/1115.jpg" onmousemove="mouseneter(event)" onmouseout="removephoto()" /> <img src="img/1211.jpg" onmousemove="mouseneter(event)" onmouseout="removephoto()" /> <img src="img/534.jpg" onmousemove="mouseneter(event)" onmouseout="removephoto()" /> <img src="img/60.jpg" onmousemove="mouseneter(event)" onmouseout="removephoto()" /> <!--<script src="JavaScript2.js"></script>--> </body> </html>

7th Jul 2020, 7:52 AM
Amir Vk
Amir Vk - avatar
1 Resposta