S
S
Sergey Goryachev2017-04-04 10:20:08
css
Sergey Goryachev, 2017-04-04 10:20:08

How to make a jQuery Cookie so it will be remembered?

Yesterday's question about Cookies led to the need to use them anyway.
https://jsfiddle.net/webirus/t95b0qt7/
Here's what I get.
When you click on the .link block, the color of the .block changes to black, adding a class.
When we first log in, we get Undefind, since the cookie is unknown to us.
Then the cookie is written, it can be seen if you click on the block and then do Run.
But how to make the block remain black even after reloading the page?
And when you go to other pages of the site?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2017-04-04
@webirus

after var status = $.cookie('blockColor');insert
status && $(".block").addClass(status);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question