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

Detailed explanation of jQuery.isFunction() function usage examples

巴扎黑
Release: 2017-06-30 13:53:15
Original
1335 people have browsed it

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 this static function.

jQuery.isFunction( object )

Parameters

Parameter Description

object Any type of any value 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
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template