Home  >  Article  >  Web Front-end  >  Detailed explanation of jQuery.isFunction() function usage

Detailed explanation of jQuery.isFunction() function usage

巴扎黑
巴扎黑Original
2017-07-08 11:26:132150browse

jQuery.isFunction() function is used to determine whether the specified parameter is a function.

This function belongs to the global jQuery object.

Syntax

jQuery 1.2 adds the static function.

jQuery.isFunction( object )

Parameters

Parameters

Description

object Any value of any type that needs to be judged.

Return value

jQuery.isFunction()The return value of the function is of Boolean type. If the specified parameter is a JS function object, it returns true, otherwise it returns false.

Example & Description

The jQuery sample code for the jQuery.isFunction() function is as follows:

//在当前页面内追加换行标签和指定的HTML内容
function w( html ){
    document.body.innerHTML += "<br/>" + html;
}
function foo(){
    alert("CodePlayer");    
}
w( $.isFunction( foo ) ); // true
w( $.isFunction( function(){ } ) ); // true
w( $.isFunction( new Function("x", "y", "return x + y;") ) ); // true
w( $.isFunction( null ) ); // false
w( $.isFunction( true ) ); // false
w( $.isFunction( { } ) ); // false
w( $.isFunction( [ ] ) ); // false

The above is the detailed content of Detailed explanation of jQuery.isFunction() function usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn