首页 > 解决方案 > 使用Bootstrap单击“我同意”后如何使栏消失

问题描述

在此处输入图像描述有谁知道如何在单击“我同意”后使该栏消失?我一直在寻找引导程序,但找不到解决方案。请帮忙。下面是我的代码:

<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&nbsp;
              <a class="color-oil" href="/assets/static/downloads/privacy-policy.pdf" target="_blank">Privacy&nbsp;Policy</a>&nbsp;—&amp;nbsp; &nbsp;<a tabindex="0" href="#" class="cm-close color-deepblue">I&nbsp;Agree</a>
            </div>
          </div>

标签: javascripthtmlbootstrap-4bootstrap-modal

解决方案


由于您使用的是 Bootstrap,请尝试使用 jQuery:

$('.color-oil').on('click', function() {
    $('#cookie-message').hide()
})
  1. 您正在向链接添加点击事件侦听器
  2. 当点击发生时,我们得到 div 并调用 hide 方法。

请让我知道这对你有没有用。


推荐阅读