Your general premise is good. See this example. To do this I
- Create a clone of the hovered list item
- Use
offset
to position it properly - On mouseleave remove the hovered element
Hover
caused unnecessary flashing. Thus the reason for the separate event handling.
var $clone;
$('li').mouseenter( function() {
$clone = $('<span />', {text: $(this).text(), class:'temp'});
$clone.css({position:'absolute', top:$(this).offset().top, left:$(this).offset().left});
$('body').append($clone);
});
$('body').on('mouseleave', 'span', function() {
$(this).remove();
});