gpt4 book ai didi

twitter-bootstrap - Bootstrap 表单中的提交按钮对输入键没有反应

转载 作者:行者123 更新时间:2023-12-01 08:52:55 26 4
gpt4 key购买 nike

我有以下 Bootstrap 形式:

<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×,
</span>
</button>
<h4 class="modal-title">Datei speichern
</h4>
</div>
<div class="modal-body">
<p>Gib einen Dateinamen ein
</p>
<div class="form-group">
<label class="input-label" for="project-bar-input">
</label>
<input type="text" class="form-control" id="project-bar-input">
</div>
</div>
<div class="modal-footer">
<button type="button" class="modal-cancel btn btn-default" data-dismiss="modal">Abbrechen
</button>
<button type="submit" class="modal-action btn btn-primary" data-dismiss="modal">Speichern
</button>
</div>
</div>
我尝试使用
$( ".modal-content" ).find( "input#submit" ).click( function() {
// submit
});
捕获 ENTER 键事件
阅读后:

Submit button not working in Bootstrap form


但它不起作用。为什么?

最佳答案

$(function(){
$('.modal-content').keypress(function(e){
if(e.which == 13) {
//dosomething
alert('Enter pressed');
}
})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×,
</span>
</button>
<h4 class="modal-title">Datei speichern
</h4>
</div>
<div class="modal-body">
<p>Gib einen Dateinamen ein
</p>
<div class="form-group">
<label class="input-label" for="project-bar-input">
</label>
<input type="text" class="form-control" id="project-bar-input">
</div>
</div>
<div class="modal-footer">
<button type="button" class="modal-cancel btn btn-default" data-dismiss="modal">Abbrechen
</button>
<button type="submit" class="modal-action btn btn-primary" data-dismiss="modal">Speichern
</button>
</div>
</div>

关于twitter-bootstrap - Bootstrap 表单中的提交按钮对输入键没有反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36821036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com