findClosestAnchor
Finds the anchor node closest to the given node
, if any.
- Use a
for
loop andNode.parentNode
to traverse the node tree upwards from the givennode
. - Use
Node.nodeName
andString.prototype.toLowerCase()
to check if any given node is an anchor ('a'
). - If no matching node is found, return
null
.