我越来越未捕获类型错误undefined不是函数上.empty()方法。代码是uncaught typeerror undefined不是函数上.empty()
title: "Criteria: "+ (criteriaText.empty() ? (criteriaIncludeText.empty()? criteriaExcludeText : criteriaIncludeText) : criteriaText)
在上面的代码中,criteriaText和criteriaIncludeText具有值。我可以在我的警报消息中看到。 jQuery使用的版本是1.7。我不确定它为什么给出未捕获的typeerror undefined不是一个有适当值的函数。有人请帮忙吗?
编辑
这些变量得到他们的价值观,通过下面的代码。
var criteriaText = jQuery(".categorySelect option[value='"+categoryId+"']").text();
var criteriaIncludeText = jQuery(".categorySelectInclude option[value='"+categoryId+"']").text();
var criteriaExcludeText = jQuery(".categorySelectExclude option[value='"+categoryId+"']").text();
我想代替'criteriaText.empty()'你需要使用'criteriaText.length == 0',检查字符串作为一些文本 – Satpal 2014-11-03 07:20:22
这个错误发生的对象有价值,但没有函数 – mfarouk 2014-11-03 07:21:01
'函数isEmpty(str)返回(!str || 0 === str.length);我想用这个来检查是否为空 – harishr 2014-11-03 07:22:05