I searched a lot for questions, but I did not find the right path. My problem: I want to dynamically create a div , showing it on a mouseover , adding it to another div and removing (via the remove() function) on mouseout . I tried a couple of ways, but in any of them, sometimes a div appears and then disappears, sometimes it's not, sometimes it disappears when my mouse leaves the text in the div container. Thanks guys.
This is my code.
var usr = 'username_pre'; var newdiv = $('<div>', { html: '<a href="#" title="">'+usr+'</a> </br> <a href="#" title="">impostazioni</a> </br> <a href="#" title="">esci</a>' }); $("#container").mouseover(function(){ $("#options").css('visibility','visible').append(newdiv); }); $("#options").mouseout(function(){ $(newdiv).remove(); });
source share