Eyes Exercise

Posted on March 12, 2023 (Last modified on November 16, 2023) • 1 min read • 75 words

These eyes will follow your cursor

Eyes Exercise

Eyes Exercise

For this exercise I used vanilla JS to make two eyeballs follow the cursor. First, I utilized the getElementsByClassName() function (elements, not element) to select both eyes. I then used the onmousemove function to calculate the x and y coordinates of the mouse as it moves across the browser. Next with some clever math and a for loop for assignment, I move the eye balls using CSS transforms.

View Repository View Live Project
Follow me

I'm interested in books, bikes, black cats, architecture and all things Chicago!