I need to compare values from two tables that are identical but contain some different data. I must find and highlight that diff. How can I do that?
<table class="TableA">
<tr>
<td>Head1</td>
<td>Some_Value</td>
</tr>
<tr>
<td>Head2</td>
<td>SomeValue</td>
</tr>
</table>
<table class="TableB">
<tr>
<td>Head1</td>
<td>Some_Value</td>
</tr>
<tr>
<td>Head2</td>
<td>SomeValueDiffValue</td>
</tr>
</table>
I need to compare this two tables and highlight diff in value cells with jquery, in above example I need to highlight SomeValueButDiff in second table
Ok, I modified Ahmet’s code into this:
$(".TableB tr").each(function () {
if ($(this).find("td")[1].innerHTML !=
$(".TableA").find("td")[1].innerHTML) {
$(this).find("td")[1].bgColor = "red";
}
});
This works for me, thx Ahmet.
You need to edit code if you have multi data cells in a row.
JsFiddle