I have a function that I want to be able to allow passing in either a regular javascript DOM element object or a jQuery object. If its not yet a jQuery object I will then make it one.
Does anyone know of a very reliable way to detect this.
function functionName(elm){
//Detect if elm is not a jquery object in condition
if (elm) elm = $(elm);
}
A logical approach is to detect one of the properties of the DOM element object. The question is, which property would be the most reliable to detect?
I could also just make it a jquery object either way since jQuery doesn't have a problem with something like: $($imajQueryObjAlready); However, the purpose of this question is not to just solve the problem, but to find a good way to detect if its a DOM object vs. a jQuery object.