我是php开发的新手,如果堆栈中已经问过这个问题,我也很抱歉。我在模型弹出输入字段中的自动对焦遇到了麻烦。
以下是我正在应用的代码,它在本地主机中工作,但在live中不工作。请帮助
这是我的代码:
$(document).ready(function(){
$("#myModal").on('shown.bs.modal', function(){
$(this).find('input[type="text"]').focus();
});
});
对于使用show.bs.modal,在必须创建事件模态show之前,可以使用show.bs.modal,请尝试以下操作:
$(document).ready(function() {
$("#myModal").modal("show");
});
$("#myModal").on('shown.bs.modal', function(){
$(this).find('input[type="text"]').focus();
});