I would like to get the id of the parent tag using javascript. In this example, the parent id of the text "stackoverflow" is "sofsite" and the parent id of "This" is "sofbody".
<body id = 'sofbody'>
This is <a href = "www.stackoverflow.com" id = "sofsite">stackoverflow</a>.
</body>
var parentid = textnode.parentNode.id;
See docs for parentNode
.