Показать сообщение отдельно
  #12 (permalink)  
Старый 10.01.2018, 16:19
Профессор
Отправить личное сообщение для Nexus Посмотреть профиль Найти все сообщения от Nexus
 
Регистрация: 04.12.2012
Сообщений: 3,733

Сообщение от рони
???
"новичок" кода не поймет
Так, по-моему мнению, код читается лучше:
(function(i) {
	var colors = ["red", "green", "blue"], use_color;
	[].forEach.call(document.querySelectorAll("#t1 tr"), function(row, index, next_row) {
		next_row=next_row[++index];
		if(row.cells[i].textContent == next_row.cells[i].textContent){
			use_color=use_color || colors.shift();
			row.style.backgroundColor = use_color;
			next_row.style.backgroundColor = use_color;
		}else if(use_color){
			colors.push(use_color);
			use_color=undefined;
		};
	});
})(0);
Ответить с цитированием