© 本文档使用 php.cn手册 发布
测试对象是否为函数。
注意:jQuery 1.3以后,在IE浏览器里,浏览器提供的函数比如'alert'还有 DOM 元素的方法比如 'getAttribute' 将不认为是函数
用于测试是否为函数的对象
检测是否为函数
1
2
3
4
5
6
7
8
9
10
11
12
13
function stub() {
function
stub() {
}
var objs = [
var
objs = [
function () {},
() {},
{ x:15, y:20 },
null,
stub,
"function"
];
jQuery.each(objs, function (i) {
jQuery.each(objs,
(i) {
var isFunc = jQuery.isFunction(objs[i]);
isFunc = jQuery.isFunction(objs[i]);
$("span:eq( " + i + ")").text(isFunc);
$(
"span:eq( "
+ i +
")"
).text(isFunc);
});
[ true,false,false,true,false ]