繁体   English   中英

如何设置关闭按钮的cookie

[英]How to set cookie for close button

我想在按下关闭按钮时设置cookie,以防止对话框再次打开。

这是我的代码:

<div class="card">
  <span class="clickable" data-effect="fadeOut"><i class="fa fa-times"></i></span>
    <div class="card-blockquote">Free shipping </div>
</div>

<script>
jQuery('.close-icon').on('click',function() {
  jQuery(this).closest('.card').fadeOut();
})
</script>

更新:

我添加此库:

<action method="addLinkRel"><rel>text/javascript</rel><href>https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.2/js.cookie.js</href></action>

我使用以下代码:

 $.cookie('card', 'card', { expires: 7 });

我在控制台中:

TypeError: $.cookie is not a function

您可以使用cookie生成器。 这里

<script>
jQuery('.close-icon').on('click',function() {
  jQuery(this).closest('.card').fadeOut();
$.jCookies({
    name : 'Your_cookie_Namee',
    value : {cookie values}
});

})
</script>

因此,如果您想使用本地存储,可以使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM