效果
原理
- 引入
Bootstrap
和 jQuery
- 在
弹框
中加入输入框,同时 自动获得焦点
- 在
点击确定
,获取 输入框的值
,进行相应流程操作
代码
js
function ShowCreateModal(title){
$("#createFileTitle").text(title);
$('#createFileMModal').modal('show');
}
$("#createFileSureBut").click(function (){
$("#createFileMModal").modal("hide");
var inputFileName = $("#fileName").val();
console.log("input file name : " + inputFileName);
});
html
<div class="modal fade" id="createFileMModal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="createFileTitle">创建文件</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="fileName" class="col-form-label">文件名</label>
<input type="text" autofocus class="form-control" id="fileName">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="createFileSureBut">确定</button>
</div>
</div>
</div>
</div>