开发者

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

开发者 https://www.devze.com 2023-04-12 17:01 出处:网络
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 so

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

精彩评论

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

关注公众号