I have given you one approach to reach your goal the rest of milestone you need to travel alone :)
<script>
function changePrevRowColor(elem) {
//document.getElementById(elem).style.backgroundColor= "white";
var lastIndex = elem.lastIndexOf("_");
var lastsubstringIndex = (elem.substring(lastIndex + 1, elem.length)) - 1;
if (lastsubstringIndex < 0) {lastsubstringIndex = 0; }
document.getElementById(elem.substring(0, lastIndex) + "_" + lastsubstringIndex).style.backgroundColor = '#FFCCCC';
}
</script>
LISTVIEW:
<asp:ListView ID="lstTest" runat="server" ClientIDMode="Predictable" >
<ItemTemplate>
<asp:Label ID="lblRowId" runat="server" Text='<%#Bind("col1") %>' onclick="javascript:(changePrevRowColor(this.id));"></asp:Label>
</ItemTemplate>
</asp:ListView>