 <pre><code>elem.nextSibling.nodeValue.replace('\n', '') </code></pre> <p>The replace is to get rid of the newline (may be different on different OSes, I am running Windows) character which is there for some reason.</p>