function next(element) { if ("nextElementSibling" in element) return element.nextElementSibling; while (element = element.nextSibling) if (element.nodeType === 1) return element; return null; }