4

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/

Rusi Nova
  • 2,617
  • 6
  • 32
  • 48
  • Duplicate of **[Check if object is a jQuery object](http://stackoverflow.com/questions/1853223)** – hippietrail Oct 20 '12 at 19:07
  • possible duplicate of [Check if object is a jQuery object](http://stackoverflow.com/questions/1853223/check-if-object-is-a-jquery-object) – ruffin Sep 01 '15 at 19:42

2 Answers2

12

Use instanceof:

console.log(elm instanceof jQuery);

or:

console.log(elm instanceof $);

Demo: http://jsfiddle.net/karim79/8jUKX/

karim79
  • 339,989
  • 67
  • 413
  • 406
3

Try the instance of

obj instanceof jQuery
mas-designs
  • 7,498
  • 1
  • 31
  • 56