[Solved] How do I change where an image is when it is following my pointer?


Instead of hard-coding image width, which is a bad practice and also hard to maintain, you could use CSS transform: translateX(-50%) attribute which does the work even if you change the image altogether in the future.

$(document).mousemove(function(e){
    $("#image").css({left:(e.pageX)})});
#image{
position:absolute;
transform: translateX(-50%)
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<img id="image"  title="foo" src="https://cdn3.imggmi.com/uploads/2019/7/24/5274c06660578c6f2b538d23ff87b7e9-full.png"/>

0

solved How do I change where an image is when it is following my pointer?