function replaceText(elem, newText) { if (elem.childNodes.length == 1 && elem.firstChild.nodeType == 3) { elem.firstChild.nodeValue = newText } }