我的页面中有这段代码。
$(document).ready(function () {
$("#ba_object_Code").change(function () { $("#HRBK").val($(this).val()); });
$.cookie('cookie_name', 'cookie_value');
if (sessid == 'xyz') {
$("#ControlPlanID").removeAttr('disabled');
}
$(".t-grid-action.t-button.t-state-default.t-grid-add").click(function () {
$.cookie('sessid', 'xyz');
});
});
我收到这个错误
Microsoft JScript 运行时错误:对象不支持此属性或方法
最佳答案
你没有定义sessid,所以当你调用它时,它会失败。
参见工作示例:http://jsfiddle.net/zNDHN/
$(document).ready(function () {
var sessid = $.cookie('sessid');
$("#ba_object_Code").change(function () { $("#HRBK").val($(this).val()); });
$.cookie('cookie_name', 'cookie_value');
if (sessid == 'xyz') {
$("#ControlPlanID").removeAttr('disabled');
console.log('cookie_found');
}
$(".t-grid-action.t-button.t-state-default.t-grid-add").click(function () {
$.cookie('sessid', 'xyz');
console.log('cookie_created');
});
});
关于javascript - jquery cookie 插件或代码在页面中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7907652/