Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.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
Jquery确认不工作_Jquery_Jquery Ui_Confirm_Confirmation - Fatal编程技术网

Jquery确认不工作

Jquery确认不工作,jquery,jquery-ui,confirm,confirmation,Jquery,Jquery Ui,Confirm,Confirmation,我试过这个:。字符串“你确定这一点吗”只是出现在我的浏览器中,当我单击按钮时,什么也没有发生 <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Dialog - Modal confirmation</title> <link rel="stylesheet" href="jquery-ui.min.css"> <scrip

我试过这个:。字符串“你确定这一点吗”只是出现在我的浏览器中,当我单击按钮时,什么也没有发生

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Dialog - Modal confirmation</title>

  <link rel="stylesheet" href="jquery-ui.min.css">
  <script src="external/jquery/jquery.js"></script>
  <script src="jquery-ui.min.js"></script>

  <script>
   $("#dialog").dialog({
   autoOpen: false,
   modal: true,
   buttons : {
        "Confirm" : function() {
            alert("You have confirmed!");            
        },
        "Cancel" : function() {
          $(this).dialog("close");
        }
      }
    });

    $("#callConfirm").on("click", function(e) {
      e.preventDefault();
      $("#dialog").dialog("open");
    });
  </script>
</head>
<body>
<button id="callConfirm">Confirm!</button>

<div id="dialog" title="Confirmation Required">
  Are you sure about this?
</div>
</body>
</html>

jQuery UI对话框-模式确认
$(“#对话框”)。对话框({
自动打开:错误,
莫代尔:是的,
按钮:{
“确认”:函数(){
警告(“您已确认!”);
},
“取消”:函数(){
$(此).dialog(“关闭”);
}
}
});
$(#callConfirm”)。在(“单击”上,函数(e){
e、 预防默认值();
$(“对话框”)。对话框(“打开”);
});
确认!
你确定吗?
截图:


尝试将js代码放在document ready函数中,它应该可以工作

$(function() {
  $("#dialog").dialog({
    autoOpen: false,
    modal: true,
    buttons: {
      "Confirm": function() {
        alert("You have confirmed!");
      },
      "Cancel": function() {
        $(this).dialog("close");
      }
    }
  });

  $("#callConfirm").on("click", function(e) {
    e.preventDefault();
    $("#dialog").dialog("open");
  });
});
希望这有帮助

编辑:另外,添加/更改jquery和css包括:

 <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

注意:您需要在下面添加cdn链接

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery-
       confirm/3.3.2/jquery-confirm.min.css">   
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery- 
       confirm/3.3.2/jquery- confirm.min.js"></script>


 $("#btnSubmit").click(function(){

     $.confirm({

     title: 'Confirmation !!',

      content: 'Are you sure, delete this item?',

       buttons: {

        confirm: function () {
         // write your logic    
                 },      
         cancel: function () { 

        } }

        });


        });

$(“#btnsupmit”)。单击(函数(){
美元。确认({
标题:“确认!!”,
内容:“确实要删除此项目吗?”,
按钮:{
确认:函数(){
//写下你的逻辑
},      
取消:函数(){
} }
});
});

您真的想使用Jquery的对话吗?javascript basic confirmbox难道还不够吗?@kyori:是的。我无法使用确认框,因为浏览器会阻止其他对话框打开(例如Chrome)。请选中此项。它在起作用,现在起作用了。我的jquery和css与你的不同。谢谢。另外,我将我的include改成了这个以使它工作: