Use .nodeName rather than .tagName.