Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Добраться до ячеек таблицы через DOM (https://javascript.ru/forum/events/2600-dobratsya-do-yacheek-tablicy-cherez-dom.html)

twolf 21.01.2009 17:27

target.parentNode.parentNode.cells;

то что нужно! а я с сиблингами мучался. Спасибо!

gcolor 21.01.2009 17:29

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Hello!</title>
  <script language="javascript" type="text/javascript">
  function Go(asder){
  table=asder;
xrow=table.getElementsByTagName("td");
for (j=0;j<xrow.length;j++)
   {
   xrow[j].innerHTML="changed";
}
  }
  </script>
</head>

<body>

<table>
<tr onclick="Go(this);">
<td>some text1</td>
<td>some text2</td>
</tr>
<tr onclick="Go(this);">
<td>some text1</td>
<td>some text2</td>
</tr>
<tr onclick="Go(this);">
<td>some text1</td>
<td>some text2</td>
</tr>
<tr onclick="Go(this);">
<td>some text1</td>
<td>some text2</td>
</tr>
<tr onclick="Go(this);">
<td>some text1</td>
<td>some text2</td>
</tr>
</table>

</body>

</html>


Часовой пояс GMT +3, время: 00:50.