I have the following code. This code contains 5 divs where when clicking on each one, the one that was clicked receives a value of background.I want that after clicking on one of them, on the next click, the one that was clicked loses the beckground without changing the others.
EX: I clicked the div 1, it became red. I clicked on div 2, it turned red, I clicked on div 1 it lost red color, but 2 has to continue red.
$(function () {
$('.Classe').click(function () {
$(this).css('background','red');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><html><divclass="Classe">valor 1</div>
<div class="Classe">valor 2</div>
<div class="Classe">valor 3</div>
<div class="Classe">valor 4</div>
<div class="Classe">valor 5</div>
<html/>