I would like only the current div to change. I would like to randomize the divs. How to preface?
$(document).ready(function() {
$('.cores').click(function() {
$('#1').css("background","red");
});
$('.cores').click(function() {
$('#2').css("background","red");
});
$('.cores').click(function() {
$('#3').css("background","blue");
});
$('.cores').click(function() {
$('#4').css("background","blue");
});
$('.cores').click(function() {
$('#5').css("background","silver");
});
$('.cores').click(function() {
$('#6').css("background","silver");
});
$('.cores').click(function() {
$('#7').css("background","pink");
});
$('.cores').click(function() {
$('#8').css("background","pink");
});
$('.cores').click(function() {
$('#9').css("background","orange");
});
$('.cores').click(function() {
$('#10').css("background","orange");
});
$('.cores').click(function() {
$('#11').css("background","yellow");
});
$('.cores').click(function() {
$('#12').css("background","yellow");
});
/*animacao*/
$('.cores').mouseenter(function() {
$(this).animate({
height: '+=10px'
});
});
$('.cores').mouseleave(function() {
$(this).animate({
height: '-=10px'
});
});
});
body{
background-color:#121213;
}
div{
/*tamanho*/
height: 100px;
width: 100px;
border: 2px;
border-radius: 5px;
background-color: #30aaaa;
display: inline-block;
margin:50px 20px 10px 40px;
}
div.principal{
margin-left: 300px;
border-radius: 5px;
background-color: #306080;
height: 500px;
width: 700px;
}
div div:hover{
background-color:#306aaa;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script><linkrel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script src="js/script.js" type="text/javascript"></script>
</head>
<body>
<div class="principal">
<div id="1" class="cores"></div>
<div id="2" class="cores"></div>
<div id="3" class="cores"></div>
<div id="4" class="cores"></div>
<div id="5" class="cores"></div>
<div id="6" class="cores"></div>
<div id="7" class="cores"></div>
<div id="8" class="cores"></div>
<div id="9" class="cores"></div>
<div id="10" class="cores"></div>
<div id="11" class="cores"></div>
<div id="12" class="cores"></div>
</div>
</body>
</html>