-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?

4

1 回答 1

2

You can use the instanceof operator:

obj instanceof jQuery

So, your code goes like :

function func(obj) {
    if (!(obj instanceof jQuery)) {
        obj = $(obj);
    }
    // ...
}
于 2012-04-12T12:59:58.563 回答