jquery - 在模式上显示弹出窗口

标签 jquery html css modal-dialog popup

我想在我的用例中的模式上显示一个弹出窗口。我无法通过模态隐藏或显示任何弹出窗口或任何其他 div。没有为弹出窗口设置顶部和左侧位置。 我已经尝试过 z-index 但它没有用。

CSS:

<button id="button1">click</button>
<div class="modal" id="abc">
   <div class="content">
       <h1>Hi</h1>
       <div id="popupabc" hidden="hidden">
         <h1>Hello</h1>
       </div>
   </div>
</div>

JQuery:

$(function(){

$("#button1).on('click',function(e){
   $("#abc").modal('show');
});

$(document).on('click',function(e){
   // getting mouse click positions left(x) and top(y).
   $("#popupabc").css({position:'absolute',left:x,top:y});
   $("#popupabc").show();
});

}

最佳答案

<script type="text/javascript">
         function ShowPopup(title, body) {
             $("#MyPopup .modal-title").html(title);
             $("#MyPopup .modal-body").html(body);
             $("#MyPopup").modal("show");
         }
</script>
     <style>
      blink {
        animation: blinker 0.6s linear infinite;
        color: #1c87c9;
       }
      @keyframes blinker {  
        50% { opacity: 0; }
       }
       .blink-one {
         animation: blinker-one 1s linear infinite;
       }
       @keyframes blinker-one {  
         0% { opacity: 0; }
       }
       .blink-two {
         animation: blinker-two 1.4s linear infinite;
       }
       @keyframes blinker-two {  
         100% { opacity: 0; }
       }
    </style>

    <div id="MyPopup" class="modal fade" role="dialog" style="margin-top: 236px;margin-left: 245px;width:500px">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    &times;</button>
                <h4 class="modal-title">
                      <%--<img src="../../Images/banner.jpg" class=" img-responsive" style="width: 100%; height:450px">--%>
                    <blink>Here you can type any message which you want..!!</blink>
                </h4>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">
                    Close</button>
            </div>
        </div>
    </div>
</div>

--这个是在aspx.cs代码中添加的------ ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup();", true);

关于jquery - 在模式上显示弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55759738/

相关文章:

javascript - 为什么在执行 ajax 请求时我的页面会锁定?

jquery - 在 Jquery 中使用按钮加载 DIV

html - 试图模仿 Lamborghini.com 的布局无济于事

html - 如何将图片放在导航栏的左侧?

html - 如何将段落与文本字段对齐

jquery - 什么最快 : single selector or multiple

jquery - 如何获取 bootstrap-fileinput 中的响应数据?

html - WordPress 内容不响应 Bootstrap 自定义主题

javascript - 使用 z-index 在父 <div class> 上方显示 <ul class>?

php - 在表格单元格中对齐