Skip to content

Instantly share code, notes, and snippets.

@jccovey
Created April 2, 2009 18:13
Show Gist options
  • Save jccovey/89328 to your computer and use it in GitHub Desktop.
Save jccovey/89328 to your computer and use it in GitHub Desktop.
// Unnecessary when JQuery is available. Returns the first element
// of [elementType] in the DOM tree whose ID contains [name].
function _getElementByPartialName(name, elementType) {
var elements = document.getElementsByTagName(elementType);
for (var i = 0; i < elements.length; i++) {
if (elements[i].getAttribute("id").indexOf(name) > -1) {
return elements[i];
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment