enter image description here,有人知道单击“我同意”后如何使该栏消失吗?我一直在寻找引导程序,但找不到解决方案。请帮忙。下面是我的代码:
<div id="cookie-message" class="cookie-message notification center-horizontal bottom static enable">
<div class="strip color-ash" >
<span class="show-tablet">We use cookies to deliver our services.</span>
By using our website, you agree to the use of cookies as described in our
<a class="color-oil" href="/assets/static/downloads/privacy-policy.pdf" target="_blank">Privacy Policy</a> — <a tabindex="0" href="#" class="cm-close color-deepblue">I Agree</a>
</div>
</div>
答案 0 :(得分:0)
由于您使用的是Bootstrap,请尝试使用jQuery:
MainModule
让我知道它是否对您有用。
答案 1 :(得分:0)
具有核心响应类.cm-close.color-deepblue
的目标链接;向其添加事件侦听器;然后点击parentNode
(div id =“ cookie-message”)不显示任何内容。
<div id="cookie-message" class="cookie-message notification center-horizontal bottom static enable">
<div class="strip color-ash">
<span class="show-tablet">We use cookies to deliver our services.</span> By using our website, you agree to the use of cookies as described in our
<a class="color-oil" href="/assets/static/downloads/privacy-policy.pdf" target="_blank">Privacy Policy</a> — <a tabindex="0" href="#" class="cm-close color-deepblue">I Agree</a>
</div>
</div>
<script>
document.querySelector('.cm-close.color-deepblue').addEventListener('click', (event) => event.target.parentNode.style = "display:none")
</script>
带有bar的简化版本为:
<div id="bar">
<div id="cookie-message">
<div>
By using our website, you agree to the use of cookies as described in our
<a href="#">Privacy Policy</a> — <a href="#" class="link">I Agree</a>
</div>
</div>
</div>
<script>
document.querySelector('.link').addEventListener('click', () => document.querySelector('#bar').style = "display:none")
</script>