Published in: JavaScript
Traverses the DOM tree and reports if any IDs are over 30 characters in length. Doesn't check for doubled IDs because that's caught when validationg the HTML.
var allTags = document.body.getElementsByTagName('*'); var ids = []; var longId = 0; for (var tg = 0; tg< allTags.length; tg++) { var tag = allTags[tg]; if (tag.id) { ids.push(tag.id); if (tag.id.length > 30) longId++; } } alert(longId + " out of " + ids.length + " IDs are too long.")
You need to login to post a comment.
