Показать сообщение отдельно
  #6 (permalink)  
Старый 23.12.2017, 12:04
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,072

kolya200598,
<!DOCTYPE HTML>

 <html>

 <head>
 <title>Untitled</title>
 </head>

 <body>

 <table>
 <tr>
 <td id = "num1"><p class = "text">2</p></td>
 <td id = "num2"><p class = "text">0</p></td>
 <td id = "num3"><p class = "text">2</p></td>
 <td id = "num4"><p class = "text">-2</p></td>
 </tr>
 </table>
 <script>
 var p = document.querySelectorAll('td p');
 for (var i=0; i<p.length; i++) {
 var num = +p[i].textContent;
 if(num  < 0 ) p[i].parentNode.style.backgroundColor = "#FFFF00";
 // if(num ....)

 }

 </script>
 </body>
 </html>
Ответить с цитированием