JavaScript ElementTraversal proposal
27 July W3 announced a new Working Draft, called: ElementTraversal This is a "new" feature but today it's not cross browser so this is my proposal to have Element Trasversal with every recent browser: (ElementTraversal = function(node){ this.node = node; this.firstElementChild = this.getFirstElementChild(); this.lastElementChild = this.getLastElementChild(); this.previousElementSibling = this.getPreviousElementSibling(); this.nextElementSibling = this.getNextElementSibling(); this.childElementCount = this.getChildElementCount(); }).extend(null, { getFirstElementChild:function(){ for(var c = this.node.childNodes, i = 0, j = (c && c.length) || 0, e; i i++ ){ if(c[i].nodeType === 1) e = c[j = i]; }; return e; }, getLastElementChild:function(){ for(var c = this.node.childNodes, i = ((c && c.length) || 0) - 1, j = -1, e; i > j; i-- ){ if(c[i].nodeType === 1) e = c[j = i]; }; return e; }, ...