javascript - JQuery 未捕获类型错误

标签 javascript jquery google-chrome

在 Chrome 调试器中,当解析这段代码时,我收到一个 Uncaught TypeError: undefined is not a function :

var pay = '{{payt}}';

if (pay.contains('visa')){
 $('#visa').prop('checked', true);
}

但是这在 Firefox 中不会导致任何问题并执行代码。什么会导致此错误?

编辑:indexOf()有效 -

if (pay.indexOf("visa")!=-1){
 $('#visa').prop('checked', true);
}

最佳答案

根据 MDN Documentation ,chrome尚不支持.contains函数。

关于javascript - JQuery 未捕获类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25464542/

相关文章:

javascript - 将元素滚动到页面底部的 View 中

javascript - Jquery/Javascript 外部文件不起作用

JavaScript 对象不一致

google-chrome - 检测 Chrome 分阶段推出

javascript - 为什么 Ajax 不发布到服务器?

c# - 有没有办法以编程方式导出/保存生成的 javascript 和 css 包?

javascript - 如何添加天数以获取当前日期的下一个日期(不含周末)

javascript - 总是成功的 jQuery promise ?

google-chrome - IndexedDB - boolean 索引

linux - 使用 shell 脚本在 centos linux 上安装 chrome