чуть покороче
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.component {
background-color: Chocolate;width:100%; height: 100px; margin-top: 10px;
}
</style>
</head>
<body>
<div class="tabs-wrap">
<button class="tab" data-color="gray">Gray</button>
<button class="tab" data-color="red">Red</button>
<button class="tab" data-color="blue">Blue</button>
</div>
<div class="component" ></div>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
$(function() {
var el = $(".component");
function fn(b) {
b && el.css("backgroundColor", b);
return el.css("backgroundColor")
}
var a = fn();
$(".tabs-wrap").on("click", ".tab", function() {
var b = fn(),
c = $(this).data("color");
fn(c);
fn() == b && fn(a)
});
});
</script>
</body>
</html>