# Javascript - follow the mouse

**URL:** <https://forum.freecodecamp.org/t/javascript-follow-the-mouse/250759>\
**Category:** General\
**Created:** [January 11, 2019, 7:34am UTC](https://forum.freecodecamp.org/t/javascript-follow-the-mouse/250759 "2019-01-11T07:34:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![divya0999](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/divya0999/32/104145_2.png) [@divya0999](https://forum.freecodecamp.org/u/divya0999)\
**Post date:** [January 11, 2019, 7:34am UTC](https://forum.freecodecamp.org/t/javascript-follow-the-mouse/250759/1 "2019-01-11T07:34:42Z")

</div>

```auto
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Minion</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<img class="minion" src="https://cdn.tutsplus.com/psd/uploads/legacy/0613_Minion/43.jpg"> 
<div class="vision">
 <div class="eye">
    <div class="ball"></div>
  </div>
</div>

<script>
  var ball= document.getElementsByClassName("ball");
  document.onmousemove = function(){
    var x = event.clientX + 100 / window.innerWidth + "%";
  
   var y = event.clientY + 100 / window.innerHeight + "%";
  
  
  for (var i=0; i<2; i++){
    ball[i].style.left = x;
     ball[i].style.top = y;
     
  }
 }
  </script>
	
</body>
</html>

```

.vision{  
position: absolute;  
top:50%;  
left:50%;  
transform:translate(-35%,-320%);  
width:100%;

}

.eye{  
width:190px;  
height:190px;  
background: white;  
border-radius:50%;  
position: relative;  
display:inline-block;  
margin:0 60px;  
border:20px solid #8395a7;  
overflow:hidden;  
}

.ball{

position:absolute;  
width:30px;  
height: 30px;  
background-color:#222f3e;  
border:8px solid #576574;  
border-radius:50%;  
top:18%;  
left:20%;  
transform: translate(-50%,-50%);  
}

```auto

Can someone please explain why the eye is not following the mouse.
p.s: its not responsive yet Please check on mobile device screen size

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:06pm UTC](https://forum.freecodecamp.org/t/javascript-follow-the-mouse/250759/2 "2021-01-17T20:06:24Z")

</div>

Closed on January 17, 2021, 8:06pm UTC


