gpt4 book ai didi

javascript - 单击时通知栏不会关闭

转载 作者:太空宇宙 更新时间:2023-11-03 22:34:29 24 4
gpt4 key购买 nike

尝试在页面底部创建一个隐私政策通知栏,并且只对新访问者显示。希望在点击接受时取消通知。现在,该栏固定显示在页面底部,但我似乎无法让通知栏在点击时关闭。

<span class="banner tracking-banner p-t-1">
<div class="container">
<div class="row">
<div class="col-sm-10 text-left m-b-1">
This website uses cookies and other 3rd party services to customize and provide you a more personalized experience. To find out more, see our <a href="/privacy/">Privacy Policy</a>.
</div>
<div class="col-sm-2 m-b-1">
<button class="dismiss btn btn-sm btn-block btn-invert">Accept</button>
</div>
</div>
</div>
</span>

JS

$(".banner").fadeIn("slow").append(".container");
$(".dismiss").click(function(){
$(".banner").fadeOut("slow");
});

最佳答案

将您的代码包装在文档就绪函数中

$(document).ready(function(){

$(".banner").fadeIn("slow").append(".container");
$(".dismiss").click(function(){
$(".banner").fadeOut("slow");
});
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<span class="banner tracking-banner p-t-1">
<div class="container">
<div class="row">
<div class="col-sm-10 text-left m-b-1">
This website uses cookies and other 3rd party services to customize and provide you a more personalized experience. To find out more, see our <a href="/privacy/">Privacy Policy</a>.
</div>
<div class="col-sm-2 m-b-1">
<button class="dismiss btn btn-sm btn-block btn-invert">Accept</button>
</div>
</div>
</div>
</span>

关于javascript - 单击时通知栏不会关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47147480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com