How to change a table row color when clicked and back to what it was originally when another row clicked?

Posted by user1277222 on Stack Overflow See other posts from Stack Overflow or by user1277222
Published on 2012-03-18T17:49:17Z Indexed on 2012/03/18 17:54 UTC
Read the original article Hit count: 134

Filed under:
|

As the title explains, I wish to change the color of a row when it is clicked then revert the color when another is clicked, however still change the color of the newly clicked row.

A resolution in JQuery would be much appreciated. I just can't crack this one. What I have so far but it's not working for me.

function loadjob(jobIDincoming, currentID){
$("#joblistingDetail").load('jobview.php' , {jobID: jobIDincoming}).hide().fadeIn('100');
var last = new Array();
last.push(currentID);
$(last[last.length-1]).closest('tr').css('background-color', 'white');
$(currentID).closest('tr').css('background-color', 'red');};

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery