This method stores the active string in a variable. The $ at the beginning of the variable is just my own Hungarian designation for jQuery objects.
var $activeRow; $('#myGrid tr').click(function() { if ($activeRow) $activeRow.removeClass('active'); $activeRow = $(this).addClass('active'); });
nickf source share