Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 对话框关闭时添加侦听器?_Javascript_Jquery_Jquery Ui - Fatal编程技术网

Javascript 对话框关闭时添加侦听器?

Javascript 对话框关闭时添加侦听器?,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,在此小提琴中显示一个对话框: 小提琴代码: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Dialog - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes

在此小提琴中显示一个对话框:

小提琴代码:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#dialog" ).dialog();
  });
  </script>
</head>
<body>

<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>

jQuery UI对话框-默认功能
$(函数(){
$(“#dialog”).dialog();
});
这是用于显示信息的默认对话框。可以使用“x”图标移动、调整和关闭对话框窗口

如果单击“X”按钮或对话框上的某个按钮关闭对话框,我是否可以添加一个侦听器来激发该侦听器?

当然,请使用对话框的


是的。您应该真正熟悉所使用元素的文档。世界不需要另一个复制/粘贴开发人员。
$(function () {
    $("#dialog").dialog({
        close: function (event, ui) {
            alert('Closed!')
        }
    });
});