jQuery.isFunction()Method
Examples
Test whether some arguments are functions
<div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div>
<div>jQuery.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 Yourself »
Definition and Usage
The $.isFunction() function is used to determine whether the specified parameter is a function.
Note:From jQuery 1.3 onwards, for example in Internet Explorer, browser-provided functions like alert() and DOM element methods (such as getAttribute()) are not considered functions.
Syntax
$.isFunction( object )
| Parameters | Description |
|---|---|
| object | Any type. Any value that needs to be determined. |
More Examples
Test the specified parameter
Determine whether the passed argument is a function.
Other Extensions
jQuery Miscellaneous Methods