Jump to content

childNode problem.


Scip

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/163782-childnode-problem/
Share on other sites

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);
}

Link to comment
https://forums.phpfreaks.com/topic/163782-childnode-problem/#findComment-864236
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.