【发布时间】:2014-02-28 20:16:13
【问题描述】:
我有一个行为异常的脚本。
console.log (typeof button);
console.log ('IsNAN ' + isNaN(button));
console.log ('isNumeric ' + jQuery.isNumeric(button));
console.log ();
当按钮是一个对象时,isNaN 应该返回 true;因为对象是NaN。但是控制台显示不同:
object
IsNAN false // should be true!
isNumeric false
这是为什么呢?
编辑:有问题的脚本是http://flesler-plugins.googlecode.com/files/jquery.serialScroll-1.2.2.js
第 126 行@函数跳转(e, button)。
【问题讨论】:
-
是空白对象吗?听起来
isNaN正在将您的 falsy 对象类型转换为 0 -
您能分享一下
button是如何定义的吗? -
Firebug 显示该按钮是:a#next-photo。如果我没记错的话,那就是 jQuery 或 HTMLObject。
标签: javascript