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://codercto.com/courses/l/35.html
How Tomcat Works
Budi Kurniawan、Paul Deck / BrainySoftware / 2004-4-1 / USD 54.95
A Guide to Developing Your Own Java Servlet Container一起来看看 《How Tomcat Works》 这本书的介绍吧!