国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > JS > 正文

BootStrap模態(tài)框和select2合用時(shí)input無(wú)法獲取焦點(diǎn)的解決方法

2024-05-06 16:39:24
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

bootstrap的模態(tài)框里使用select2插件,會(huì)導(dǎo)致select2里的input輸入框沒有辦法獲得焦點(diǎn),沒有辦法輸入.

解決方法:

1.

把頁(yè)面中的  tabindex="-1"  刪掉(測(cè)試成功):

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header">  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>  <h3 id="myModalLabel">Panel</h3> </div><div class="modal-body" style="max-height: 800px"><div id="myModal" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header">  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>  <h3 id="myModalLabel">Panel</h3> </div><div class="modal-body" style="max-height: 800px">

可以在onshown方法里面做處理,主要原理就是因?yàn)閎ootstrap的tabindex='-1',占用了select2的tabindex='0'腳本做處理 模態(tài)框顯示出來(lái)后,將模態(tài)框的tabindex屬性刪掉

BootstrapDialog.show({   onshown: function (dialogRef) {    $("#"+dialogRef.getId()).removeAttr("tabindex");  }})

2.

重寫enforceFocus方法(測(cè)試發(fā)現(xiàn)沒有效果):

$.fn.modal.Constructor.prototype.enforceFocus = function() {};

總結(jié)

以上所述是小編給大家介紹的BootStrap模態(tài)框和select2合用時(shí)input無(wú)法獲取焦點(diǎn)的解決方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JavaScript/Ajax教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 杭州市| 云南省| 兴化市| 东乌珠穆沁旗| 锡林郭勒盟| 虞城县| 灵石县| 镇原县| 固镇县| 新巴尔虎右旗| 台湾省| 大同市| 象山县| 萍乡市| 宁安市| 朝阳县| 留坝县| 黄石市| 澄江县| 兰西县| 潼南县| 芜湖市| 五华县| 通榆县| 滁州市| 金门县| 沙雅县| 延边| 巨野县| 西盟| 衡水市| 邮箱| 天镇县| 河西区| 峨眉山市| 临城县| 安阳县| 海阳市| 昭通市| 成都市| 陇川县|