jQuery $.cookie is not a function

前端 未结 7 1574
眼角桃花
眼角桃花 2020-11-27 15:12

I am trying to set a cookie using jQuery:

$.cookie(\"testCookie\", \"hello\");
alert($.cookie(\"testCookie\"));

But when I load my page, I

7条回答
  •  萌比男神i
    2020-11-27 15:38

    I had this problem as well. I found out that having a $(document).ready function that included a $.cookie in a script tag inside body while having cookie js load in the head BELOW jquery as intended resulted in $(document).ready beeing processed before the cookie plugin could finish loading.

    I moved the cookie plugin load script in the body before the $(document).ready script and the error disappeared :D

提交回复
热议问题