我有一个 bootstrap 模态弹出窗口,它的第一个是下拉列表,我希望用户能够在字段中进行表格操作,而无需使用鼠标在模态弹出窗口中设置焦点。如果第一个字段是文本框,我可以很好地做到这一点,但是当它是下拉列表时,我无法使用 ddl_list.Focus() 命令将其聚焦。
经过一些进一步的搜索,这个问题得到了解决。只需将以下 javascript 添加到 aspx 文件中。这将焦点设置到引导弹出窗口模式中的字段字段。
<script type="text/javascript">
$('body').on('shown.bs.modal', function (e) {
var ele = $(e.target).find('input[type=text],textarea,select').filter(':visible:first'); // find the first input on the bs modal
if (ele) {ele.focus();} // if we found one then set focus.
})
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句