日期:2014-05-16 浏览次数:20346 次
var k; var a = {}; for(var i in a){ k++; } if(k == 0){ return; }
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <script type="text/javascript"> function objIsNull(obj){ if(obj){ alert("This obj is exist!"); }else{ alert("This obj is null"); } } </script> <body> <!--不为null的例子--> <input type="button" value="exist" onclick="objIsNull(this)"/> <!--为null的例子--> <input type="button" value="null" onclick="objIsNull()"/> </body> </html>