在 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/