-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
  • 24,666
  • 27
  • 90
  • 147

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,324
  • 6
  • 35
  • 56