zoukankan      html  css  js  c++  java
  • bootstrap模态框和select2合用时input无法获取焦点

    在bootstrap的模态框里使用select2插件,会导致select2里的input输入框没有办法获得焦点,没有办法输入.

    解决方法:

    1.把页面中的  tabindex="-1"  删掉:

    <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">

    2.重写enforceFocus方法:

    $.fn.modal.Constructor.prototype.enforceFocus = function() {};
  • 相关阅读:
    【redis】主从复制
    【redis】订阅功能
    【redis】基础
    MySQL【十二】pymysql操作数据库
    MySQL【十一】创建索引
    MySQL【十】认识索引
    MySQL【九】树
    MySQL【八】多表查询
    ubuntu 制作ISO模块
    ubuntu 开机自启动
  • 原文地址:https://www.cnblogs.com/hjsblogs/p/6290006.html
Copyright © 2011-2022 走看看