jQuery.isFunction()方法
jQuery 教程
· 2019-03-28 21:38:35
实例
测试一些参数是否为函数
<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>
定义和用法
$.isFunction()函数用于判断指定参数是否是一个函数。
注意:jQuery 1.3之后的版本,例如在 Internet Explorer 中,由浏览器提供的函数alert(),以及 DOM 元素方法(比如 getAttribute())将不被认为是函数。
语法
$.isFunction( object )
参数 | 描述 |
---|---|
object | 任意类型 需要进行判断的任意值。 |
点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html
Understanding Machine Learning
Shai Shalev-Shwartz、Shai Ben-David / Cambridge University Press / 2014 / USD 48.51
Machine learning is one of the fastest growing areas of computer science, with far-reaching applications. The aim of this textbook is to introduce machine learning, and the algorithmic paradigms it of......一起来看看 《Understanding Machine Learning》 这本书的介绍吧!