【jQuery api】isFunction()

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4   <meta charset="utf-8">
 5   <title>jQuery.isFunction demo</title>
 6   <style>
 7   div {
 8     color: blue;
 9     margin: 2px;
10     font-size: 14px;
11   }
12   span {
13     color: red;
14   }
15   </style>
16   <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
17 </head>
18 <body>
19  
20 <div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div>
21 <div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div>
22 <div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div>
23 <div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div>
24 <div>jQuery.isFunction( objs[ 4 ] ) = <span></span></div>
25  
26 <script>
27 function stub() {}
28 var objs = [
29   function() {},
30   { x:15, y:20 },
31   null,
32   stub,
33   "function"
34 ];
35  
36 jQuery.each( objs, function( i ) {
37   var isFunc = jQuery.isFunction( objs[ i ]);
38   $( "span" ).eq( i ).text( isFunc );
39 });
40 </script>
41  
42 </body>
43 </html>
1 jQuery.isFunction( objs[ 0 ] ) = true
2 jQuery.isFunction( objs[ 1 ] ) = false
3 jQuery.isFunction( objs[ 2 ] ) = false
4 jQuery.isFunction( objs[ 3 ] ) = true
5 jQuery.isFunction( objs[ 4 ] ) = false

Description: Determine if the argument passed is a JavaScript function object.

转载于:https://www.cnblogs.com/dream-to-pku/p/5973576.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值