Sna*_*apa 30 javascript jquery modal-dialog twitter-bootstrap
我需要能够使用onClick=""或类似的功能打开Twitter引导模式窗口.只需要代码进入onClick="".我想点击一下div打开模态.
代码摘录:
Div代码:
<div class="span4 proj-div" onClick="open('GSCCModal');">
Run Code Online (Sandbox Code Playgroud)
模态Div代码:
<div id="GSCCModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
function open(x){
$(x).modal('show');
}
Run Code Online (Sandbox Code Playgroud)
Bri*_*nna 41
你不需要onclick.假设您正在使用Bootstrap 3 Bootstrap 3文档
<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>
Run Code Online (Sandbox Code Playgroud)
如果你使用的是Bootstrap 2,你可以按照这里的标记:http: //getbootstrap.com/2.3.2/javascript.html#modals
Ash*_*Ash 13
我正在寻找onClick选项,根据列表中的项目设置模态的标题和正文.T145的答案帮了很多忙,所以我想分享一下我如何使用它.
确保包含JavaScript函数的标记是text/javascript类型以避免冲突:
<script type="text/javascript"> function showMyModalSetTitle(myTitle, myBodyHtml) {
/*
* '#myModayTitle' and '#myModalBody' refer to the 'id' of the HTML tags in
* the modal HTML code that hold the title and body respectively. These id's
* can be named anything, just make sure they are added as necessary.
*
*/
$('#myModalTitle').html(myTitle);
$('#myModalBody').html(myBodyHtml);
$('#myModal').modal('show');
}</script>
Run Code Online (Sandbox Code Playgroud)
现在可以在onClick方法中从一个元素(如按钮)内部调用此函数:
<button type="button" onClick="javascript:showMyModalSetTitle('Some Title', 'Some body txt')"> Click Me! </button>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
166802 次 |
| 最近记录: |