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);
}
Answer
Use instanceof
:
console.log(elm instanceof jQuery);
or:
console.log(elm instanceof $);
Demo: http://jsfiddle.net/karim79/8jUKX/
No comments:
Post a Comment