使用javascript onClick显示Bootstrap模式 [英] Display Bootstrap Modal using javascript onClick
本文介绍了使用javascript onClick显示Bootstrap模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够使用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代码:
<div id="GSCCModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Javascript:
function open(x){
$(x).modal('show');
}
推荐答案
您不需要onclick.假设您正在使用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
这篇关于使用javascript onClick显示Bootstrap模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文