javascript - 单击链接时 jquery ui 对话框未在 html 中打开

标签 javascript jquery html css jquery-ui

我试图在点击一个链接时在 html 页面中打开一个对话框,但它向我显示了一个错误,比如在 ie 中点击对象不支持属性或方法“对话框”。

请检查下面的代码

源文件

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

对话代码

$("#link").click(function(c){

                e.preventDefault();
          var dialog = $('<p>Are you sure?</p>').dialog({

            buttons: {
                "Yes": function() {alert('you chose yes');},
                "No":  function() {alert('you chose no');},
                "Cancel":  function() {
                    dialog.dialog('close');
                }
            }
        });
            }); 
            });

最佳答案

将“c”替换为“e”并移除末尾的右括号。你有太多了。

$("#link").click(function(e){

            e.preventDefault();
      var dialog = $('<p>Are you sure?</p>').dialog({

        buttons: {
            "Yes": function() {alert('you chose yes');},
            "No":  function() {alert('you chose no');},
            "Cancel":  function() {
                dialog.dialog('close');
            }
        }
    });
        }); 

关于javascript - 单击链接时 jquery ui 对话框未在 html 中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29887513/

相关文章:

javascript - 是否需要在发送 post 请求之前对 payload 进行加密?

javascript - 类型错误 : Backbone. $ 未定义

jquery ajax成功后提交空表单

html - WCAG anchor 链接

html - 如何使用 CSS 将图像应用于特定边框?

javascript - 如何在 HTML IMG 标签中使用 JavaScript math.round?

javascript - FullCalendar:过滤多种类型的事件

javascript - jQuery dataTable 列的自定义排序

javascript - 具有 knockout 数据绑定(bind)的 TinyMCE 不会更新

jQuery - Turn.js 仅使用页面剥离效果