I have table with selectable cells and now I try to prevent selecting more than two cell at once. It should work like that: If I click cell id 4 then it should get class selected if next I click cell id 16 then it also should get class selected but if next I click cell id 20 then cell id 4 should have removed class selected and id 20 should get class selected.
I already have something like that jsfiddle
$(".currency-cell").click(function(){
if ($(this).hasClass("selected"))
$(this).removeClass("selected");
else {
$(this).addClass("selected");
}).hover(function(){
$(this).css("background","gold");
},
function(){
if($(this).hasClass("selected"))
$(this).css("background","gold");
else
$(this).css("background","silver");
});