How can I tell the difference between a regular object and a jquery object (page element)?

// var = {hey: "baby"};
// or 
// var = $('#thingy');

if(typeof var == 'object'){  // this is true for both =(
}

I need my code to be smart enough to be able to talk about the difference between the two. What is the best way to do this?

+3
source share
1 answer

You can use the instanceof operator to do this.

obj instanceof jQuery

Also, I don't think you want to use "var" as the variable name. It is reserved for setting a variable area.

+1
source

All Articles