<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
.wrap > div {
width: 50px;
height: 50px;
line-height: 50px;
cursor: pointer;
border: 1px dashed #ccc;
text-align: center;
}
.active {
background: #f00;
}
</style>
<div class="wrap">
<div>1</div>
<div>3</div>
<div>2</div>
<div>4</div>
</div>
<script>
var wrap = $('.wrap > div');
wrap.click(function (){
$(this).toggleClass('active');
$('.wrap > div').not($(this)).removeClass('active');
});
</script>