NextSibling Skipping Whitespace
From GreaseSpot
A simple helper to follow .nextSibling properties, but skip text nodes to return elements.
function nextSibling(start) {
var nextSib;
if (!(nextSib=start.nextSibling)) {
return false;
}
while (nextSib.nodeType!=1) {
if (!(nextSib=nextSib.nextSibling)) {
return false;
}
}
return nextSib;
}
Example Usage:
if (nextSib=nextSibling(element)) {
alert(nextSib.innerHTML);
}