BIGserg,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.red{
background:#FF0000
}
.green{
background-color: #008000;
}
td {
background-color: #FFFACD;
}
div{
width: 100px;
height: 30px;
}
.color{
display: none;
}
.select{
border: dashed 2px #8B4513;
margin: -4px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(function(){
var el;
function setColor()
{ $(".table_id td").removeClass("select");
var color = $(this).data("color");
el.addClass(color).data("color",color);
$(".color").hide()
}
$(".table_id").on("click", "td", function() {
var color = $(this).data("color");
$(".table_id td").removeClass("select")
if(color){ $(this).removeClass(color).removeData("color");$(".color").hide() }
else {
el=$(this);
el.addClass("select");
$(".color").show()}
})
$(".color").on("click", setColor)
})
</script>
</head>
<body>
<table width="400" class="table_id" >
<thead>
<tr>
<th>Title 1</th>
<th>Title 2</th>
<th>Title 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1.1</td>
<td>Cell 1.2</td>
<td>Cell 1.3</td>
</tr>
<tr>
<td>Cell 2.1</td>
<td>Cell 2.2</td>
<td>Cell 2.3</td>
</tr>
</tbody>
</table>
<div class="color red" data-color="red"></div>
<div class="color green" data-color="green"></div>
</body>
</html>