jquery cookie set value to boolean true

后端 未结 4 1197
太阳男子
太阳男子 2020-12-17 21:16

I am using this jquery.cookie plugin and I need to set value to TRUE or NULL/FALSE.

I am trying to do it like this: $.cookie(\'ff\', true, { expires: 30, path:

4条回答
  •  自闭症患者
    2020-12-17 21:56

    Another way to do this is

    var mycookie = !($.cookie("cookiename")=='false')
    

    Or:

    if(!($.cookie("cookiename")=='false')){ 
        //mycode 
    }
    

    If the value is 'false' then ($.cookie("cookiename")=='false') will return true so we invert it by using ! which return false

    if the value is not 'false' then it will return false so we invert it by using ! which return false

提交回复
热议问题