隐藏Popup Div无法正常工作

时间:2018-02-19 12:34:58

标签: javascript c# html css asp.net

我有一个弹出式div我想让它在点击一个asp按钮时可见但问题是当我点击弹出div的关闭范围时它不会隐藏,虽然它在页面加载事件中工作正常它隐藏在那里,但是当它被asp按钮看到时它并没有隐藏。

javascipt的:

<script type="text/javascript">
     $(function () {
         $("#popup_homeBanner .close").click(function () {
             $("#popup_homeBanner").hide();
         });
     });
</script>

HTML:

<div runat="server" id="divBanner" visible="False">
    <div id="popup_homeBanner">    
        <span class="close icon-cancel">close</span>
        <div style="margin: 5% 10% 5% 20%; padding: 10px; border: 0px solid; 
             border-radius: 20px; width: 60%; height: 80%; background-color: 
             #FFFFFF; background-image: url('Banner/Announcement.jpg');  
             background-repeat: no-repeat;
             background-position: center center; background-size: cover;"> 
        </div>
    </div>
</div>

C#:

protected void btnShow_Click(object sender, EventArgs e)
 {
    divBanner.Visible = true;   
 }

CSS:

#popup_homeBanner{float:Left; width:100%; height:100%; left:0; top:0; position:fixed; z-index:100; background: url(../images/opacity_bg.png) left top repeat; text-align:center; display:block;}
#popup_homeBanner .close{position:absolute; display:inline-block; background:#fff; width:50px; padding-right:6px;
-webkit-border-radius: 15px;    
-border-radius: 15px;    
-moz-border-radius:15px;
-khtml-border-radius:15px; margin-top:16px; left:50%; cursor:pointer;}

1 个答案:

答案 0 :(得分:0)

我不能以你的方式绑定close函数。试试这个:

var purchaseOrdered = {};
for (let object in purchase) {
   purchaseOrdered[object.userId].price += object.price;
}