Created
April 21, 2011 12:53
-
-
Save ryck/934422 to your computer and use it in GitHub Desktop.
Get tag by rel attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getElementByRel(rel) { | |
aElements = document.getElementsByTagName("link"); | |
relElems = []; | |
for (i = 0; i < aElements.length; i++) { | |
if (aElements[i].hasAttribute("rel") && aElements[i].rel == rel) { | |
return aElements[i]; | |
} | |
} | |
} | |
tag = getElementByRel('author'); | |
alert(tag.href); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment