Take the parent node, get its name node, then compare with the name of the node you want. To make sure something is a link (and not some other anchor), check to see if it has a filled href property.
node.parentNode.nodeName.toLowerCase() === 'a' && node.parentNode.href !== "";
source
share