简体   繁体   English

将 cookie 用于 Javascript 功能

[英]Use cookie for Javascript function

I have a Javascript function :我有一个 Javascript 函数:

$('.myclass').click(function() {
  $('.myclass2').each(function(e) {
    $(this).removeClass('myclass3').addClass('myclass4');
  });
});

I would wish that the changes remain all the time for the user with jquery cookie .我希望使用jquery cookie的用户始终保持更改。

Do you know how can it be done?你知道怎么做吗?

Use jQuery Cookie plugin:使用jQuery Cookie插件:

Set a cookie设置一个 cookie

$.cookie("example", "foo");

Get a cookie得到一块饼干

alert($.cookie("example"));

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

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