我正在使用以下 Bootstrap 代码来显示模式,现在我想从输入字段获取值。我尝试了很多方法,但未能使用 javascript 获取数据。
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Forgot Password ?</h4>
</div>
<div class="modal-body">
<p>Enter your employee id below to reset your password.</p>
<input type="text" name="getId" placeholder="Employee id" autocomplete="off" class="form-control placeholder-no-fix">
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
<button class="btn btn-primary" btn="submt" type="button">Submit</button>
</div>
</div>
</div>
</div>
$(document).ready(function () {
var btnSubmit = $(element).parent().prev().find("#submt");
$(btnSubmit).click(function()
{
//var ids = $('getId').val();
var ids = $(element).parent().prev().find("#getID");
alert(ids);
$.ajax({
url:'rtrv_pass.php',
type:'post'
//data:{uid:},
});
});
});
最佳答案
我刚刚修改了您的点击事件代码..
Jquery:
$('#btnSubmit').click(function () {
var textFieldVal = $('input[name="getId"]').val();
$.ajax({
url: 'rtrv_pass.php',
type: 'post'
//data:{uid:},
});
});
关于jquery - 如何从模式中检索文本框数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37109475/