there version of image following mouse:
and i've tried make work dynamically loaded image this:
var = new image(); a.src = 'https://upload.wikimedia.org/wikipedia/commons/6/6a/this_is_a_demo_blue_dot.png'; a.onload = g; function g(){ $(document).mousemove(function(e){ $(a).css({left:e.pagex, top:e.pagey}); }); }
but doesn't work. need work way since going have draw on canvas later on.
i guess problem jquery can't find image way, how make work?
set id
element , append in dom
as position : absolute;
being applied through css
, applying id
on image element essential.
var = new image(); a.id = 'image'; a.src = 'https://upload.wikimedia.org/wikipedia/commons/6/6a/this_is_a_demo_blue_dot.png'; $('body').append(a); a.onload = g; function g() { $(document).mousemove(function(e) { $(a).css({ left: e.pagex, top: e.pagey }); }); }
#image { position: absolute; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
Comments
Post a Comment