[英]I want to use a div as a twitter bootstrap modal link
Can help me? 可以帮我? I want to use a div as a twitter bootstrap modal link. 我想使用div作为Twitter引导模式链接。 when i will click on a div it will call a modal. 当我单击div时,它将称为模式。 is it possible? 可能吗? if possible then please show me a way. 如果可能的话,请告诉我一种方法。 I think it is possible but i dont know how to do this. 我认为这是可能的,但我不知道该怎么做。 please help me. 请帮我。
Use $modal.modal('show');
使用$modal.modal('show');
in your onclick
event handler. 在您的onclick
事件处理程序中。
HTML: HTML:
<div class="my-div"></div>
<div class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
JavaScript: JavaScript:
var $modal = $('.modal').modal({
show: false
});
$('.my-div').on('click', function() {
$modal.modal('show');
});
Here is a demo link . 这是一个演示链接 。
Your HTML: 您的HTML:
<div data-toggle="modal" href="#example">Launch modal</div>
<div id="example" class="modal hide fade in" style="display: none;">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>This is a Modal Heading</h3>
</div>
<div class="modal-body">
<h4>Text in a modal</h4>
<p>You can add some text here.</p>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-success">Call to action</a>
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
Your JS (assumes you are already including the needed bootstrap files, both JS and CSS): 您的JS(假设您已经包含了所需的引导文件,包括JS和CSS):
$(function () {
$("#example").modal({show:false});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.