jQuery.isFunction() method
Example
Test whether some arguments are functions
<
div
jQuery.isFunction( objs[ 0 ] ) =
<
span
span
div
<
divjQuery.isFunction( objs[ 1 ] ) =
<
span
span
div
<
divjQuery.isFunction( objs[ 2 ] ) =
<
span
span
div
<
divjQuery.isFunction( objs[ 3 ] ) =
<
span
span
div
<
divjQuery.isFunction( objs[ 4 ] ) =
<span span div>
<script$(function(){function stub(){}var objs=[function(){},{x>:
15
,
y
:
20
}
,
null
,
stub
,
"
function
"
]
; $.
each
(
objs
,
function
(
i
)
{
var
isFunc
= $.
isFunction
(
objs
[
i
]
)
; $
(
"
span
"
)
.
eq
(
i
)
.
text
(
isFunc
)
;
}
)
;
}
)
script
Try it »
Definition and Usage
The $.isFunction() function is used to determine whether the specified argument is a function.
**Note:** In versions after jQuery 1.3, functions provided by the browser, such as alert() in Internet Explorer, and DOM element methods (such as getAttribute()) are not considered functions.
Syntax
$
.isFunction( object )
| Parameters | Description |
|---|---|
| object | Any type: The arbitrary value to be checked. |
More examples
Check the specified argument
Determine whether the passed argument is a function.
jQuery Miscellaneous Methods