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});
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745470762a4629121.html
评论列表(0条)