-2

Possible Duplicate:
Check if object is a jQuery object

I need something like:

function func(obj) {
    if (!$.isJQ(obj)) {
        obj = $(obj);
    }
    // ...
}

Is there any isJQ function in jQuery?

Community
  • 1
  • 1
Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153

1 Answers1

2

You can use the instanceof operator:

obj instanceof jQuery

So, your code goes like :

function func(obj) {
    if (!(obj instanceof jQuery)) {
        obj = $(obj);
    }
    // ...
}
tusar
  • 3,364
  • 6
  • 37
  • 60