bootstrap 3 modal window not working

2019-04-12 00:38发布

I'm using Bootstrap 3 (full version) and I use bootstrap modal in my code:

<a data-toggle="modal" data-target="deleteMessage" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span> Удалить</a>

<!-- Modal -->
<div id="deleteMessage" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">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><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

This code I copied from official docs, but it's not working, modal window does not display.

Whats the problem?

Many thanks.

2条回答
Deceive 欺骗
2楼-- · 2019-04-12 01:26

You forgot to include # into data-target attribute

<a data-toggle="modal" data-target="#deleteMessage" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span> Удалить</a>

Live DEMO

查看更多
萌系小妹纸
3楼-- · 2019-04-12 01:27

Try to change your anchor code into:

<a data-toggle="modal" data-target="#deleteMessage" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span> Удалить</a>

It looks like there is a typo in the tutorial, there should be additional "#" in the data-target attribute.

查看更多
登录 后发表回答