使用 javascript onClick 显示引导模式
我需要能够使用 onClick=""
或类似功能打开 Twitter 引导模式窗口.只需要代码进入 onClick=""
.我正在尝试制作一个可点击的 div
来打开模式.
I need to be able to open a Twitter bootstrap modal window using the onClick=""
or similar function. Just need the code to go into the onClick=""
. I am trying to make a click-able div
to open the modal.
代码摘录:
分区代码:
<div class="span4 proj-div" onClick="open('GSCCModal');">
模态分区代码:
<div id="GSCCModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Javascript:
function open(x){
$(x).modal('show');
}
推荐答案
你不需要点击.假设您使用的是 Bootstrap 3 Bootstrap 3 文档
You don't need an onclick. Assuming you're using Bootstrap 3 Bootstrap 3 Documentation
<div class="span4 proj-div" data-toggle="modal" data-target="#GSCCModal">Clickable content, graphics, whatever</div>
<div id="GSCCModal" class="modal fade" 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">× </button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
如果您使用的是 Bootstrap 2,则应遵循此处的标记:http://getbootstrap.com/2.3.2/javascript.html#modals
If you're using Bootstrap 2, you'd follow the markup here: http://getbootstrap.com/2.3.2/javascript.html#modals
相关文章