Bootstrap 弹出框modal上层的输入框不能获得焦点问题,具体内容如下
1.在使用Bootstrap框架中目前modal弹出框只支持一层
即在当前弹出框上不能再使用modal弹出框。
如果使用自定义的弹出框,例如:
如果自定义弹出框中有input输入框,如果input 输入框不能获得焦点,则可能原因如下:
许多使用定义弹出层
<div tabindex="0" role="dialog" data-backdrop="static"> <div> <div> <div> <button type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4>添加学校</h4> </div> <div> <form novalidate> <input type="hidden" ng-model="entity.SchID" /> <div> <label for="SchName">学校名称:</label> <div> <input type="text" required ng-minlength="3" ng-maxlength="30" ng-model="entity.SchName" placeholder="长度3-30"> <span ng-show="myForm.SchName.$dirty && myForm.SchName.$invalid"> <span ng-show="myForm.SchName.$error.required">名称是必须的</span> <span ng-show="myForm.SchName.$error.minlength">最小长度3</span> <span ng-show="myForm.SchName.$error.maxlength">最大长度30</span> </span> </div> </div> <div> <label for="WebSite">学校官网:</label> <div> <input required type="url" ng-model="entity.WebSite" placeholder="链接地址" /> <span ng-show="myForm.WebSite.$dirty && myForm.WebSite.$invalid"> <span ng-show="myForm.WebSite.$error.required">姓名是必须的</span> <span ng-show="myForm.WebSite.$error.url">链接格式不正确</span> </span> </div> </div> <div> <label for="FoundTime">建校时间:</label> <div> <input required type="number" ng-model="entity.FoundTime" placeholder="年份" /> <span ng-show="myForm.FoundTime.$dirty && myForm.FoundTime.$invalid"> <span ng-show="myForm.Summary.$error.required">姓名是必须的</span> <span ng-show="myForm.Summary.$error.number">请输入数字(年份)</span> </span> </div> </div> <div> <label>入学时间:</label> <div> <div></div> <input type="hidden" ng-model="entity.MonthList" /> </div> </div> </form> </div> <div> <button type="button" ng-disabled="myForm.$invalid" ng-click="addOrUpdate()">保存</button> <button type="button" data-dismiss="modal">关闭</button> </div> </div> </div> </div>
解决方式是去掉 tabindex="0" 属性,然后就可以获得焦点了
<div role="dialog" data-backdrop="static">