使用BootStrap模态框瞬间消失,且点击没有事件的Button按钮会刷新页面

布局时吧Button按钮放在了form表单中,导致进页面时,不做任何操作,首先点击三个Button按钮,会刷新页面,新增按钮本来有的 模态框 也不会弹出来会弹出并瞬间消失,以为是js冲突的原因,删除了BootStrap的js文件,还是同样的问题。

            <div class="col-md-8">
                <form class="form-inline">
                  <div class="form-group">
                    <label for="exampleInputName2">姓名&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
                  </div>
                  &nbsp;&nbsp;&nbsp;&nbsp;
                  <div class="form-group">
                    <label for="exampleInputEmail2">邮箱&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="[email protected]">
                  </div>

                  <button class="btn btn-info"><span class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
                  <button class="btn btn-primary" id="emp_add_modal_btn"><span class="glyphicon glyphicon-plus"></span>&nbsp;新增</button>
                  <button class="btn btn-danger" id="emp_delete_btn"><span class="glyphicon glyphicon-trash"></span>&nbsp;删除</button>
                </form>
            </div>

当把三个Button按钮移出form表单,就没有出现上面的问题了

<div class="row">
            <div class="col-md-8">
                <form class="form-inline">
                  <div class="form-group">
                    <label for="exampleInputName2">姓名&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
                  </div>
                  &nbsp;&nbsp;&nbsp;&nbsp;
                  <div class="form-group">
                    <label for="exampleInputEmail2">邮箱&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="[email protected]">
                  </div>
                </form>
            </div>
            <div class="col-md-4">
                <button class="btn btn-info"><span class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
                <button class="btn btn-primary" id="emp_add_modal_btn"><span class="glyphicon glyphicon-plus"></span>&nbsp;新增</button>
                <button class="btn btn-danger" id="emp_delete_btn"><span class="glyphicon glyphicon-trash"></span>&nbsp;删除</button>
            </div>
        </div>

次篇只为记录自己开发路上的问题,望大神们多多指教。

原文地址:https://www.cnblogs.com/LionsEyes/p/8971574.html

时间: 2024-08-08 18:38:31

使用BootStrap模态框瞬间消失,且点击没有事件的Button按钮会刷新页面的相关文章

bootstrap 嵌套模态框 二级模态框关闭导致一级模态框滚动条消失

一.问题描述 实际开发中遇到bootstrap嵌套模态框,关闭次模态框后主模态框滚动条消失. 二.解决办法 在主模态框上加属性:(先凑合着用,回头再看看源码) style="overflow-y: auto;" 问题:在使用Bootstrap时,有时候会用到模态框中再嵌套模态框.这样就会出现一个问题,就是在关闭第二个模态框时,会导致第一个模态框的滚动条消失,这样就会使得屏幕太小而模态框太大看不到底部信息,而没法进行操作. 解决方法:就是在第二个模态框的关闭hide 方法调用之后立即触发

关于手动关闭BootStrap模态框

在网上找手动关闭BootStrap模态框的解决方法,说是(需要引用bootstrap.js等): $("#myModal").modal('hide'); 但是我发现我的只能关闭 , 不能关闭下面那半透明层.找了下发现是出现这两行代码的缘故. <div class="modal-backdrop fade in"></div> <div class="modal-backdrop fade in"></d

Bootstrap 模态框、轮播 结合使用

Bootstrap 模态框和轮播分开使用的教程网上很多.但是两者结合使用的例子和资料很少.两者结合使用时,开始我遇到了不少bug,现在分享给大家. 我的这个例子是把图片轮播嵌入到模态框里. 最后的效果如下图:点击页面上按钮,弹出模态框,模态框里的图片开始轮播,点击旁边空白位置,模态框消失. 代码如下: <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 轮播.模态框</title> <link

bootstrap 模态框的关闭后,背景仍然是暗色的。

这个问题是两种写法不同造成的 第一种 $('#avatar-modal').modal('hide'); 这种写法模态框会关闭,并背景恢复. 第二种 $('#avatar-modal').modal().hide(); 这种写法,模态框会消失,但暗色背景仍然在.不能操作. 所以建议bootstrap相关语法,用第一种即可. 原文地址:https://www.cnblogs.com/xiaodongxiaodong/p/8510706.html

Bootstrap模态框按钮

1.触发模态框弹窗的代码 这里复制了一段Bootstrap模态框的代码 <h2>创建模态框(Modal)</h2> <!-- 按钮触发模态框 --> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">开始演示模态框</button> <!-- 模态框(Modal) --

Bootstrap 模态框(也可以说的弹出层)

最近在尝试使用bootstrap的模态框 使用模态框主要要引入一下几个js和css: bootstrap.css jquery.1.9.1.js(这个可以灵活选择) bootstrap.js html页面的写法如下: <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css"> <script src="bootstrap/js/j

去除BOOTSTRAP模态框半透明阴影

当使用bootstrap模态框默认自带半透明阴影,如果想要去除阴影,需要怎么做呢? 今天在项目中我遇到了这个问题,想要去除模态框的阴影,试了好久都没解决.后来问同事的时候才知道,当模态框弹出后,会加上这样一句代码: <div class="modal-backdrop  in"></div> 案例:自带半透明阴影的模态框 1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta char

bootstrap模态框远程加载网页的正确处理方式

bootstrap模态框远程加载网页的方法 在bootsrap模态框文档里给出了这个方法: 使用链接模式 <a data-toggle="modal" href="tieniu.php" data-target="#modal">Click me</a> 使用脚本模式: $("#modal").modal({ remote: "tieniu.php" }); 没有给出任何实例,这种用

使用bootstrap模态框实现浮动层

authour: 陈博益 updatetime: 2015-04-22 06:52:15 friendly link: http://v3.bootcss.com/javascript/#modals 目录: 1,bootstrap模态框的使用示例 2,注意点 1,下面是一个简单的例子说明bootstrap模态框的使用: 1 <!DOCTYPE html> //modal.html 2 <html xmlns="http://www.w3.org/1999/xhtml"