我有一个在 $.each 函数中定义的函数,如下所示:
var websiteWill;
$.each(cookieConfig.cookies,function(key, value){
var levelName = key,
websiteWill = function(){
alert(this.id);
if($('#' + this.id).is(':checked')){
$.each(this.value.will,function(){
$('<li><i class="icon-ok"></i>' + this + '</li>').appendTo(parent + '-' + levelName + '.will ul');
});
}
}
});
当我尝试打电话时websiteWill();
:
$(document).delegate('.cookie-trigger', 'click',function(){
websiteWill();
});
我明白了Uncaught TypeError: undefined is not a function
编辑:我已将变量声明为全局 ^^