Home > Web Front-end > JS Tutorial > Introduction to the use of BootStrap model pop-up box_javascript skills

Introduction to the use of BootStrap model pop-up box_javascript skills

WBOY
Release: 2016-05-16 15:03:28
Original
1585 people have browsed it

Before, we explained the use of bootstrap tab. Today we will learn about the use of model pop-up window in bootstrap.

Effect:

Code:

<input id="btntext" type="button" value="添加文本组件" data-toggle="modal" data-target="#myModal" href="../SysManage/ZuJianManage.aspx"/>
<!-- Modal -->
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog">
<div class="modal-header"><button class="close" type="button" data-dismiss="modal">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body"></div>
</div>
Copy after login

It’s very simple, that’s it.

Note: The data-target attribute points to the id of the model, so click the button and the model will pop up.

Of course you can also use js to control it.

The following code:

Show: $('#myModal').modal('show');

Hide: $('#myModal').modal('hide');

Switch: $('#myModal').modal('toogle');

Event: $('#myModal').on('hidden', function () {// do something…});

Note: I used the href attribute here to let the model go to a remote url. Of course, you can write the content you want directly in the model-body.

Look carefully at the div structure of the model, and you will understand that model-body represents the content, and model-header represents the header. If you want to add two buttons at the bottom, you have to use the following code.

<div class="modal-footer">
<a href="#" class="btn">关闭</a>
<a href="#" class="btn btn-primary">保存</a>
</div>
Copy after login

Note: If you want to set the width of the model, you must add a layout. Just put the model in the code block below and set the width of the model. style="width:500px". By the way, you can't use span style and put it directly into the class. .

<div class="container"></div>
Copy after login

The above is the use of BootStrap model pop-up box introduced by the editor. I hope it will be helpful to everyone!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template