дочерние элементы и их поиск
Всем привет!!
приведите плиз очень прошу и умоляю кросс использование для получение lastChild s firstChild ,previousSibling:( |
а что именно не получается то ?
|
function getChildren( elem ){
var child = elem.firstChild, res = [];
while ( child ) {
if ( child.nodeType == 1 ) {
res [ res.length ] = child;
}
child = child.nextSibling;
}
return res;
}
var childrenNode = getChildren( node );
var firstChild = childrenNode.length ? childrenNode[0] : null;
var lastChild = childrenNode.length ? childrenNode[res.length - 1] : null;
|
| Часовой пояс GMT +3, время: 04:31. |