Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery.isFunction() method

jQuery.isFunction() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods

Example

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 »


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 MethodsjQuery Miscellaneous Methods