marcusshepp
5/26/2016 - 6:02 PM

Javascript Element Follows Mouse Movement

Javascript Element Follows Mouse Movement

// <div class="foo">I follow</div>
window.addEventListener("mousemove", function(e){
  $(".foo").css({
    left: (e.pageX - ($(window).width() * .35)),
    top: (e.pageY - 600)
  });
});