Created
November 9, 2012 11:36
Revisions
-
Tom Greuter created this gist
Nov 9, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ /** * Get parent node for given tagname * @param {Object} node DOM node * @param {String} tagname HTML tagName * @return {Object} Parent node */ function getParentByTagName(node, tagname) { var parent; if (node === null || tagname === '') return; parent = node.parentNode; tagname = tagname.toUpperCase(); while (parent.tagName !== "HTML") { if (parent.tagName === tagname) { return parent; } parent = parent.parentNode; } return parent; }