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,537
  • 6
  • 29
  • 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
  • 334,458
  • 66
  • 409
  • 405
3

Try the instance of

obj instanceof jQuery
mas-designs
  • 7,378
  • 1
  • 29
  • 56