老師,我想請問這是檢測的那個對象。
<html>
? ? <head>
? ? ? ? <title>檢測對象是否為原始對象</title>
? ? ? ? <link href="style.css" rel="stylesheet" type="text/css" />
? ? ? ? <script src="http://www.xianlaiwan.cn/data/jquery-1.8.2.min.js" type="text/javascript"></script>
? ? </head>
? ??
? ? <body>
? ? ? ? <div id="divtest">
? ? ? ? ? ? <div class="title">
? ? ? ? ? ? ? ? <span class="fl">檢測對象是否為原始對象</span>?
? ? ? ? ? ? </div>
? ? ? ? ? ? <div class="content"></div>
? ? ? ? </div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? var obj = "null";
? ? ? ? ? ? ? ? var strTmp = "您定義了一個:";
? ? ? ? ? ? ? ? if ($.isPlainObject) { //檢測是否為原始對象
? ? ? ? ? ? ? ? ? ? strTmp += "原始對象";
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ? ? strTmp += "非原始對象";
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? $(".content").html(strTmp);
? ? ? ? ? ? });
? ? ? ? </script>
? ? </body>
</html>
2016-06-15
$.isPlainObject()是指調用jquery中的工具函數,即jquery.isPlainObject
而$.isPlainObject是指這個函數本身,當然會為真了
舉個知乎里的例子
function fun(){
? ?return 5
}
var a=fun
var b=fun()
a是fun函數,而b是5