use*_*900 1 javascript cookies jquery
我正在使用jQuery Cookie插件,并且它在所有页面上工作正常,除了在主页上运行该页面我正在敲打我的头但没有运气.
我的代码看起来像:
$.cookie('CA_txtKeywords', $("#CAT_txtKeywords").val(), { expires: 7, path: '/' });
Run Code Online (Sandbox Code Playgroud)
在萤火虫中它说:
未捕获的TypeError:对象函数(a,b){return new e.fn.init(a,b,h)}没有方法'cookie'
有人可以指导这个错误是什么以及如何删除它?
你在头脑中包含了jQuery,然后你包含了cookie插件,但是在页面底部你有这个:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// You may specify partial version numbers, such as "1" or "1.3", with the same result. Doing so will automatically load the latest version matching that partial revision pattern
// (e.g. 1.3 would load 1.3.2 today and 1 would load 1.4.1).
google.load("jquery", "1");
google.setOnLoadCallback(function() {
// Place init code here instead of $(document).ready()
$(".euro").parseNumber({format:"#,###", locale:"it"});
$(".euro").formatNumber({format:"#,###", locale:"it"});
})
</script>
Run Code Online (Sandbox Code Playgroud)
使用谷歌加载器加载jQuery AGAIN.因为你再次加载jQuery,所以直接附加到文档头部的jQuery命名空间(而不是原型)的内容都会被删除.
所以归结为,为什么世界上你加载jQuery两次?
解:
删除谷歌加载器并请求它从主页的页脚加载jQuery.
| 归档时间: |
|
| 查看次数: |
1367 次 |
| 最近记录: |