美文网首页
django项目中加入使用模态框

django项目中加入使用模态框

作者: 一杯海风_3163 | 来源:发表于2018-05-18 11:13 被阅读0次

在django项目中加入模态框,首先先将以下代码复制到html文件中。

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                        onclick="closed()">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    模态框标题
                </h4>
               模态框内容
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>

在控制元素添加点击事件

<a href="#" class="btn btn-primary glyphicon glyphicon-search" data-toggle="tooltip" onclick="prom()"
   data-placement="top"
   title="使用模态框"></a>

js代码:使得点击控制元素触发模态框显示的函数。

<script type="text/javascript">
    function prom(){
        $("#myModal").modal('show');
    }

</script>

相关文章

网友评论

      本文标题:django项目中加入使用模态框

      本文链接:https://www.haomeiwen.com/subject/ajawdftx.html