var q = document.evaluate('//span[@id="karma"] | //td[text() = "karma:"]/following-sibling::td', document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE); [q.iterateNext(), q.iterateNext()].forEach(i => i.textContent = 100000);