Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to move an element to the cursor in javascript

$(document).ready(function() {
  $(this).on("click", function(e) {
    var x = e.pageX;
    var y = e.pageY;
    var el = $("#meh");
    el.css('position', 'absolute');
    el.css("left", x);
    el.css("top", y);
  })
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #move #element #cursor #javascript
ADD COMMENT
Topic
Name
9+7 =