开发者

Checking if a Variable has been assigned an Element or a String

I am building a sma开发者_Go百科ll library that involves object manipulation, and there will be an input that might be assigned an ID of an element (which will then use document.getElementById), or something like document.getElementBy... and whatever goes here.

Does anyone know how to determine if its a string or an HTML Element


typeof

http://jsfiddle.net/zeF4J/


typeof should work:

typeof variable == "string"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜