Home > Web Front-end > JS Tutorial > body text

Jquery cookie operation code_jquery

WBOY
Release: 2016-05-16 18:32:29
Original
928 people have browsed it

Writing cookies with JS is hard and easy, but it is simple. Just write document.cookie=.. directly. The difficulty is that some of the keys in the cookies already exist. I want to use JS to rewrite this. Sometimes when you use document.cookie to write, you just rewrite the key again. Sometimes the writing cannot be successful (sometimes characters that require the escape function will appear, and the specific reason is unclear). Anyway, It was very troublesome. Later I saw that there is a cookie plug-in for Jquery, which felt good. However, when tracking and debugging, I found that there was still an extra value with the same name written on the cookies, which was troublesome. Later I saw someone on the Internet talking about using this method, and I felt Not bad

$.cookie('key', '', { expires: -1, path: '/' }); You can delete the value to be reset, not bad

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template