Scip Posted June 26, 2009 Share Posted June 26, 2009 Using fire bug it seems my elements have "\n" new line statements are childNodes, is this normal? It's really annoying because i can't use firstChild or nextSibling statement. I have to pull elements using the getelementBytagName statement. Does this have something do with how html is coded? For instanace i am tyring to pull tr and td from a table but i have not nested these in a tbody tag. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 26, 2009 Share Posted June 26, 2009 yes, the whitespace between actual HTML elements is considered a "text node" specifically for tables though, you can navigate them as arrays: var rows = document.getElementById('table_name').rows; for(var r=0;r < rows.length;r++){ var cells = rows[r].cells; alert('The first cell is '+cells[0].innerHTML); } Quote Link to comment Share on other sites More sharing options...
Scip Posted June 27, 2009 Author Share Posted June 27, 2009 Thanks, i will try this next time hopefully it will make the code cleaner and less confusing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.