admin管理员组文章数量:1430603
Can help me? I want to use a div as a twitter bootstrap modal link. when i will click on a div it will call a modal. 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.
Can help me? I want to use a div as a twitter bootstrap modal link. when i will click on a div it will call a modal. 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.
Share Improve this question asked Jan 29, 2013 at 7:11 TaslimTaslim 752 silver badges8 bronze badges2 Answers
Reset to default 3Use $modal.modal('show');
in your onclick
event handler.
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:
var $modal = $('.modal').modal({
show: false
});
$('.my-div').on('click', function() {
$modal.modal('show');
});
DEMO
Here is a demo link.
Your 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):
$(function () {
$("#example").modal({show:false});
});
本文标签: javascriptI want to use a div as a twitter bootstrap modal linkStack Overflow
版权声明:本文标题:javascript - I want to use a div as a twitter bootstrap modal link - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745470762a2659737.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论