I have a JavaScript function that uses document.getElementById(). I want to upgrade it to be able to use jQuery selectors ($(this).parent().find("blah")), however it needs to be able to use the original method for backwards compatibility. Is there a way I can test if the argument passed to the function is a string (so I can use getElementById) or a jQuery object (not a string).
I could use .length, but is this a failsafe method of determining whether the argument is a string?
As long as I can test for strings, the jQuery branch can just go in an else - I don't need to make absolutely sure it's not a string, although it would be nice to test if it's jQuery too.
Thanks,
James