Easy Tutorial
❮ Sel Previous Siblings Traversing Slice ❯

jQuery.isFunction() Method

jQuery Miscellaneous Methods

Example

Testing if some parameters 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>

Definition and Usage

The $.isFunction() function is used to determine if the specified parameter is a function.

Note: In versions of jQuery after 1.3, for example in Internet Explorer, functions provided by the browser such as alert(), and DOM element methods like getAttribute() will not be considered functions.


Syntax

Parameter Description
object Any type The value to be tested.

More Examples

Determine if the specified parameter


jQuery Miscellaneous Methods

❮ Sel Previous Siblings Traversing Slice ❯