How to know an object is jQuery object or not
I have created a function which tells whether a variable hold jQuery object or on is there any substitute of this. Below is my code
/*Is there any substitute of this function*/
function iSJqueryObj(elm)
{
return elm && jQuery.isFunction(elm.html);
}
http://jsfiddle.net/kE7Lp/3/
Use instanceof
:
console.log(elm instanceof jQuery);
or:
console.log(elm instanceof $);
Demo: http://jsfiddle.net/karim79/8jUKX/
尝试一下实例
obj instanceof jQuery
链接地址: http://www.djcxy.com/p/83934.html
上一篇: 检查'this'是$(this)还是只是普通的'this'
下一篇: 如何知道一个对象是否是jQuery对象