Эффект mouseleave и mouseenter в диалоговом окне jquery
Подскажите, пожалуйста, как закрыть диалоговое окно jquery для функции mouseleaving или mouseout в jquery. У меня есть окно, когда мой курсор переходит в это окно, должно открыться диалоговое окно, и когда курсор покидает это окно, а также диалоговое окно, диалоговое окно должно закрываться автоматически.
Спасибо,
Вот мой код, пожалуйста, скажите мне, где изменить,
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$("#text,#dialog").mouseenter(function(){
$( "#dialog" ).dialog({
position: {
my: "left+25 top+20",
at: "left+25 top+20"}
});
} );
$("#text,#dialog").mouseout(function(){
$( "#dialog" ).dialog("close");
} );
});
</script>
</head>
<body>
<textarea id="text"></textarea>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying
information. The dialog window can be moved, resized and closed with
the 'x' icon.</p>
</div>
</body>
</html>