Explanation
The .live()
function, that is deprecated as of JQuery 1.7 and should be replaced with the .on()
function, is used on elements that are added after the page has loaded. e.g elements the script created afterwards.
In order for the popupbox to remain visible while the user hovers the popupbox itself, it needs to be tied with the element it's currently hovering. The popup also has to be "inside" the element it's hovering, because if the user mouseleave()
s the "file" button, it will trigger that event, and there is no way around that.

Unless you want to try a timer method, this is how it'd look. (ish)

Solution
Here's an example of how it can be done.
And here's my solution:
$('.btnfile').mouseenter(function(){
$(this).prepend($("#popup"));
$("#popup").show();
}).mouseleave(function(){
$("#popup").hide();
});
Basically, I'm just prepending the popup div to the current btnfile its hovering, and then showing it. The rest is in the CSS.
Alternative solution
You could add a timer event, checking if the user left the button, and then they have "x" amount of time to hover over the popup, before the popup is being hidden.
Here's an example with the timer added.
var thisTimer = null;
var timeoutTime = 1000; //1 second
var insidePopup = false;
$("#popup").mouseenter(function(){insidePopup = true;})
.mouseleave(function(){
insidePopup = false;
$(this).hide();
});
//lots of clearTimeouts, but it is possible
$('.btnfile').mouseenter(function(){
$(this).prepend($("#popup"));
$("#popup", this).show();
clearTimeout(thisTimer);
}).mouseleave(function(){
clearTimeout(thisTimer);
thisTimer = setTimeout(function(){
if(!insidePopup)
$("#popup").hide();
clearTimeout(thisTimer);
}, timeoutTime);
});