Home >Web Front-end >JS Tutorial >Jquery cookie operation code_jquery

Jquery cookie operation code_jquery

WBOY
WBOYOriginal
2016-05-16 18:32:29950browse

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

Statement:
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