Hızlı yanıt: kod örneği
use the and properties:However in some browsers (I forget which) you also need to check for whitespace and comment nodes:Libraries like jQuery handle all these cross-browser checks for you out of the box.
nextSibling
previousSibling
<div id="foo1"></div><div id="foo2"></div><div id="foo3"></div>document.getElementById('foo2').nextSibling; // #foo3document.getElementById('foo2').previousSibling; // #foo1
var div = document.getElementById('foo2');var nextSibling = div.nextSibling;while(nextSibling && nextSibling.nodeType != 1) { nextSibling = nextSibling.nextSibling}