Check if obect is jQuery wrapper

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?


You can use the instanceof operator:

obj instanceof jQuery

So, your code goes like :

function func(obj) {
    if (!(obj instanceof jQuery)) {
        obj = $(obj);
    }
    // ...
}
链接地址: http://www.djcxy.com/p/83928.html

上一篇: 我如何检查一个变量是一个jQuery对象还是纯DOM元素?

下一篇: 检查obect是否是jQuery包装器