为了账号安全,请及时绑定邮箱和手机立即绑定

bootstrap怎么弹出窗口

bootstrap怎么弹出窗口

一只萌萌小番薯 2019-04-03 01:01:52
bootstrap怎么弹出窗口
查看完整描述

3 回答

?
守着一只汪

TA贡献1872条经验 获得超3个赞

弹出窗口,你说的应该是模态框吧。

示例代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<h2>创建模态框(Modal)</h2><!-- 按钮触发模态框 --><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">开始演示模态框</button><!-- 模态框(Modal) --><div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

                <h4 class="modal-title" id="myModalLabel">模态框(Modal)标题</h4>

            </div>

            <div class="modal-body">在这里添加一些文本</div>

            <div class="modal-footer">

                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

                <button type="button" class="btn btn-primary">提交更改</button>

            </div>

        </div><!-- /.modal-content -->

    </div><!-- /.modal --></div>


 


查看完整回答
反对 回复 2019-04-04
?
子衿沉夜

TA贡献1828条经验 获得超3个赞

使用jquery更改bootstrap弹出框的内容,可以使用Jquery的load()方法,动态加载不同的模态框(弹出框)内容,然后填充到页面的弹出框div中:

主页面只保留弹出框最外面的那个div

1

<div class="modal fade" id="myModal"> </div>

动态加载的弹出框内容页面中包括bootstrap模态框中的head、body和footer部分

1

2

3

4

5

6

7

8

9

<div class="modal-header">   

    <h3>模态框header </h3>  

</div>   

<div class="modal-body">   

    <p>模态框body</p>  

</div>   

<div class="modal-footer">   

    <p>模态框footer</p>   

</div>

利用jquery的load()方法,在点击不同的按钮时动态先动态加载内容到模态框的div中,然后再让bootstrap显示

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<script>  

// 模态对话框隐藏时移除数据  

$("#myModal").on("hidden", function() {    

        $(this).removeData("modal");  

});   

// 显示模态对话框  

var showModal = function() {   

    var remote = "/test/showModal";  

    if (remote != "") {    

        $("#myModal").load(remote, function() {    

            $("#myModal").modal('show');   

        });  

}};  

</script>

其中showModal函数可以由按钮控制。

 


查看完整回答
反对 回复 2019-04-04
  • 3 回答
  • 0 关注
  • 1719 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信