We are able to run this code
str.parentNode.nextSibling.tagName
and get the name accordingly. What we need is the nextSibling after this nextSibling so we tried this
str.parentNode.childNodes[3].tagName
is not working? Any solution to this?
Note that an element’s
nextSiblingmight be a text node, which doesn’t have a tagName property, or may not exist at all, in which casenextSiblingwill beundefinedand trying to access itstagNameproperty will throw an error.So you likely want do to something like:
and the
getNextElementSiblingfunction is something like: