我尝试应用url中显示的演示模式:
http://getbootstrap.com/javascript/
after "Varying modal content based on trigger button".
并且还使用HTML代码
<input name="email" type="email" id="email" />
...和javascript代码
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var modal = $(this)
modal.find('.modal-title').text('Log In')
modal.find('.modal-body input').val("This Body..")
$(this).find('#email').focus();//why it doesn't work????????
})
如何自动在电子邮件输入中设置焦点功能? 谢谢
答案 0 :(得分:1)
使用shown.bs.modal
代替show.bs.modal
尝试以下内容:
$('#exampleModal').on('shown.bs.modal', function (event) {
var button = $(event.relatedTarget)
var modal = $(this)
modal.find('.modal-title').text('Log In')
modal.find('.modal-body input').val("This Body..")
$(this).find('#email').focus(); //now it will work
})