I am trying to make my image follow the cursor using a specific code, but it doesn't seem to be working. I'm having trouble figuring out what's wrong with it.
Here is the code snippet that I'm currently using:
function followIt(e){
var img=document.getElementById("img");
img.style.left = e.clientX;
img.style.top = e.clientY;
}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo</title>
</head>
<style>
#img{
box-shadow: 0px 0px 1px 1px #000000;
width: 100px;
}
</style>
<body id="demo_body" onmousemove="followIt(event)">
<img src="https://i.postimg.cc/g02SqdrF/followmouse.png" id="img">
</body>
<script src="script.js" text="text/javascript"></script>
</html>