I tried to achieve this by something like this :
$('div.check').mousemove(function(e){
// Mouse click + moving logic here
$('.movestatus').text('mouse moved');
var clientCoords = "( " + e.clientX + ", " + e.clientY + " )";
$(".chords").text(clientCoords);
var ap = $("<div>OO</div>");
ap.offset({ top: e.clientX, left: e.clientY });
$("div.check").appendTo(ap);
});
What is happening when i move the mouse in the div the main div gets dissapeared or on jsfiddle nothing happens.
Demo
Where have i been going wrong
Question: How can i bind jQuery to .check such that when i move the mouse it adds a div at the moved position.
Thanks
You need to use
append, notappendTo. You also need to position absolute and swap the clientX and clientY.Working demo: http://jsfiddle.net/ubgNH/