简单的jquery对话框可以't创建输入

simple jquery dialog box can't create input

本文关键字:创建 输入 jquery 对话框 简单      更新时间:2023-10-07

有人可以帮助我在对话框中创建一个输入框吗?我使用的是jquery-ui.js。这是我的代码:

 $(document).on("click",".savebtn",function().        {
        var id = $(this).attr("id");
            $.dialog({
                title: "Activation date ",
                  content:"Activation date ",                                    
               create: function() {
                  $("#inputBox").val();
                },
                  closeBack:function(){
                    $.dialog.message({
                      content: "The id is "+ id
                    });
                  },
                  buttons:[
                    {
                      text:"Click me"
                    }
                  ]
            });
    });

你可以试试这个:

Fiddle

HTML:

<div id='dialog' style='display: none;'>
  <input type="text" />
</div>
<button>
  Click Me!
</button>

Jquery:

$(document).ready(function() {
  $("button").click(function() {
    $("#dialog").dialog({
      resizable: false,
      modal: true,
      title: "My Awesome Title",
      buttons: {
        "Do Something": function() {
          alert("Do something if I was clicked.");
        },
        Cancel: function() {
          alert("Dialog Canceled");
          $(this).dialog("close");
        }
      }
    });
  });
});