This article mainly introduces jQuery combined with the jQuery.cookie.js plug-in to implement the skin-changing function. It analyzes the common functions of the jQuery.cookie.js plug-in and the related operating skills to implement the skin-changing function in the form of examples. Friends who need it You can refer to the following
example of this article describing the use of jQuery combined with the jQuery.cookie.js plug-in to implement the skin-changing function. I share it with you for your reference. The details are as follows:
Last time I shared with you how to implement the skin-changing function, but the script code seems a bit long, so this time I plan to use the cookie.js plug-in to implement the skin-changing function. Okay, let's get started.
jQuery.cookie.js download:https://github.com/carhartl/jquery-cookie/
First let’s learn how to use cookie.js.
First import:
Then you can use it.
$.cookie('the_cookie'); //读取Cookie值 $.cookie('the_cookie', 'the_value'); //设置cookie的值 $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'example.com', secure: true});//新建一个cookie,"expires"是有效天数,"path"是保存路径,"domain"是创建 cookie的网页所拥有的域名,"secure"是cookie的传输是否使用安全协议(HTTPS) $.cookie('the_cookie', 'the_value'); //新建cookie $.cookie('the_cookie', null); //删除一个cookie
Attached code:
cookie的使用
The effect achieved is the same as the function of the previous article, and the use After using cookie.js, the code is less and easier to understand.
The above is the detailed content of Sample code for jQuery+jQuery.cookie.js plug-in to implement skin changing function. For more information, please follow other related articles on the PHP Chinese website!