function getSiblings(element, type){
var arraySib = [];
if ( type == 'prev' ){
while ( element = element.previousSiblings ){
arraySib.push(element);
}
} else if ( type == 'next' ) {
while ( element = element.nextSiblings ){
arraySib.push(element);
}
}
return arraySib;
}
Latest version: - Add example; - Fixed 'previousSiblings' into 'previousSibling'; - Fixed 'nextSiblings' into 'nextSibling';
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.