Wednesday, April 17, 2019

Check if obect is jQuery wrapper











I need something like:



function func(obj) {
if (!$.isJQ(obj)) {

obj = $(obj);
}
// ...
}


Is there any isJQ function in jQuery?


Answer



You can use the instanceof operator:




obj instanceof jQuery


So, your code goes like :



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

}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...