arianhojat Posted November 17, 2006 Share Posted November 17, 2006 i was kinda used to Flash actionscript where i can set whitespace to be avoided so.childNodes[0]andchildNodes[1]return 1st 2 nodes...However i realized Javascript returns whitespace nodes with the results so childNodes[0] and childNodes[1] actually dont return what i want...so it returns 'visually'...whitespace[0]<childNodes[1] />whitespace[2]<childNodes[3] />whitespace[4]Is there anyway, or soem function i can use that just returns the next node, avoiding everything but regular element nodes?i guess the best i could think of is a function like so...[code]function getChildNodes( parentElement, Index)//index of node to look for inside parentElement{ var actualI=0; //the current Element Node index being looked at for(var i=0; i<parentElement.childNodes; i++) //looping through all nodes { var currentNode = parentElement.childNodes[i]; if(currentNode.nodeType==1) //if current node is an Element { if(Index==actualI) //if currentNode is index looking for return currentNode; else //next Element in the loop which is found, will have the actual index value of actualI actualI++; } }}[/code] Link to comment https://forums.phpfreaks.com/topic/27600-how-to-get-childnodesx-to-look-at-only-nonwhitepace-nodes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.