简单的jquery对话框无法创建输入

时间:2016-03-31 14:44:57

标签: javascript jquery html css ajax

任何人都可以帮我在对话框中创建一个输入框吗?我正在使用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"
                    }
                  ]
            });
    });

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

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");
        }
      }
    });
  });
});