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