我有这个代码,它是从文本框中读取值,我想在尝试parseInt()之前检查''是安全的,但显然不是.
我收到错误:
未捕获的TypeError:无法调用未定义的方法'toLowerCase'
使用此代码:
var total = 0;
$.each('.reg-input', function () {
if ($(this).val() == '') {
}
else {
total += parseInt($(this).val()); //this line throwing error
}
});
if (total == 0) {
$('.RegisterContainer').hide();
}
Run Code Online (Sandbox Code Playgroud)
'.reg-input'是一个字符串,this在这种情况下也将是一个字符串,而不是一个dom元素.试试这个:
$('.reg-input').each(function(){...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14988 次 |
| 最近记录: |