So Im using the jquery cookie plugin and I need to check if a cookie is unset. I set it up something like this:
if ($.cookie('language')==null) {
}
This doesn't seem to work. Any ideas why?
简单使用:
if($.cookie("language")){}
To see what the plugin is returning, do a console.log() call:
console.log($.cookie("language"));
This should tell you what is being returned from the plugin if you monitor your Inspector / Firebug console.
I think you can get away with just doing if($.cookie("language")) but you'll have to test that.
Line #90 in the source looks like that SHOULD be the result you want. Check for any errors and test what happens if the cookie is set.
https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.