I found this script that color every time I click on a row, particular column, but I wanted to color a column, line during a certain condition.
My idea was to do the same thing: link where it is in bold
The condition would color every time there is an exchange of values in the array (changeValues (arrayNumbers [i], arrayNumbers [i + gap]);
Let's say I have this sequence of numbers.
[3] [6] [1] [7]
For example, when you make the change, you will start printing color [3] and [6] in the created table.
That is, it would look like this when you print the table: [1] [6] [3] [7]
If you look here, you can understand better:
function trocaValores(a, b){
tempValor = a.valor;
a.setValor(b.valor);
b.setValor(tempValor);
}
$('td').click(function() {
$(this).css('backgroundColor', '#000');
});
Here I create a dynamic table to "print" the array during execution (every time there is a value change, it starts this table)
function adicionaTabela() {
contador++;
var myTableDiv = document.getElementById("tabelaDinamica");
var table = document.createElement('TABLE');
table.border='1';
var tableBody = document.createElement('TBODY');
table.appendChild(tableBody);
var tr = document.createElement('TR');
tableBody.appendChild(tr);
var teste = arrayNumeros.length;
for (var j=0; j<teste; j++){
var td = document.createElement('TD');
td.width='75';
td.appendChild(document.createTextNode(arrayNumeros[j].valor));
tr.appendChild(td);
}
myTableDiv.appendChild(table);
}
Is there any way to implement this?