Bootstrap彈出框modal上層的輸入框不能獲得焦點(diǎn)問題的解決方法
Bootstrap 彈出框modal上層的輸入框不能獲得焦點(diǎn)問題,具體內(nèi)容如下
1.在使用Bootstrap框架中目前modal彈出框只支持一層
即在當(dāng)前彈出框上不能再使用modal彈出框。
如果使用自定義的彈出框,例如:http://my.oschina.net/tianma3798/blog/737232
如果自定義彈出框中有input輸入框,如果input 輸入框不能獲得焦點(diǎn),則可能原因如下:
許多使用定義彈出層
<div class="modal fade" tabindex="0" role="dialog" id="myModal" data-backdrop="static"> <div class="modal-dialog modal-lg"> <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" id="myModalLabel">添加學(xué)校</h4> </div> <div class="modal-body"> <form class="form-horizontal" name="myForm" novalidate> <input type="hidden" ng-model="entity.SchID" /> <div class="form-group"> <label for="SchName" class="col-sm-2 control-label">學(xué)校名稱:</label> <div class="col-sm-10"> <input type="text" required ng-minlength="3" ng-maxlength="30" class="form-control" ng-model="entity.SchName" name="SchName" placeholder="長度3-30"> <span class="text-danger" 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 class="form-group"> <label for="WebSite" class="col-sm-2 control-label">學(xué)校官網(wǎng):</label> <div class="col-sm-10"> <input required type="url" class="form-control" ng-model="entity.WebSite" name="WebSite" placeholder="鏈接地址" /> <span class="text-danger" 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 class="form-group"> <label for="FoundTime" class="col-sm-2 control-label">建校時間:</label> <div class="col-sm-10"> <input required type="number" class="form-control" ng-model="entity.FoundTime" name="FoundTime" placeholder="年份" /> <span class="text-danger" ng-show="myForm.FoundTime.$dirty && myForm.FoundTime.$invalid"> <span ng-show="myForm.Summary.$error.required">姓名是必須的</span> <span ng-show="myForm.Summary.$error.number">請輸入數(shù)字(年份)</span> </span> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">入學(xué)時間:</label> <div class="col-sm-10"> <div class="selectBox" id="selectMonth"></div> <input type="hidden" name="Province" ng-model="entity.MonthList" /> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-success" ng-disabled="myForm.$invalid" ng-click="addOrUpdate()">保存</button> <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button> </div> </div> </div> </div>
解決方式是去掉 tabindex="0" 屬性,然后就可以獲得焦點(diǎn)了
<div class="modal fade" role="dialog" id="myModal" data-backdrop="static">
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
node.js 一個簡單的頁面輸出實(shí)現(xiàn)代碼
最近決定重拾node.js,用它來做一個合并JS文件的東西。由于忘得差不多了,先看能不能輸出一個頁面來再說。以下是我的一些筆記,省得以后又忘凈光2012-03-03微信小程序-圖片、錄音、音頻播放、音樂播放、視頻、文件代碼實(shí)例
本篇文章主要介紹了微信小程序-圖片、錄音、音頻播放、音樂播放、視屏、文件代碼實(shí)例,有興趣的可以了解一下。2016-11-11小程序input數(shù)據(jù)雙向綁定實(shí)現(xiàn)方法
這篇文章主要介紹了小程序input數(shù)據(jù)雙向綁定實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10詳解JS中continue關(guān)鍵字和break關(guān)鍵字的區(qū)別
在javascript中continue的作用是退出當(dāng)前次循環(huán),break的作用則是一旦當(dāng)前循環(huán)有break那么直接退出整個循環(huán)。本文將通過一些示例為大家詳細(xì)講講二者的區(qū)別,感興趣的可以了解一下2022-08-08javascript二維數(shù)組轉(zhuǎn)置實(shí)例
這篇文章主要介紹了javascript二維數(shù)組轉(zhuǎn)置方法,實(shí)例分析了數(shù)組行列交換的轉(zhuǎn)置技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-01-01javascript中定義私有方法說明(private method)
本篇文章主要是對javascript中定義私有方法(private method)進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-01-01使用canvas實(shí)現(xiàn)鯉魚躍龍門的動畫效果
這篇文章主要給大家介紹了使用canvas實(shí)現(xiàn)鯉魚躍龍門的動畫效果,文中通過代碼示例給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作有一定的幫助,感興趣的小伙伴可以自己動手嘗試一下2024-02-02