Is there any Native Javascript Functions to check if html tag exists?
I mean :
var tag = "div";
alert(isValidTag(tag)) // true;
alert(isValidTag("foo")) // false;
If there is no native function for that, I will keep my function :
function isValidTag(tagName) {
var tags = ["div","span","a","link" ... "body"];
for(var i=0, len = tags.length; i++ < len; ) {
if(tags[i] == tagName) return true;
}
return false;
}
How about this: