javascript - I want to use a div as a twitter bootstrap modal link - Stack Overflow

Can help me? I want to use a div as a twitter bootstrap modal link. when i will click on a div it will

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 badges
Add a ment  | 

2 Answers 2

Reset to default 3

Use $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">&times;</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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信