-2
I would like only the current div to change. I would like to randomize the Ivs. How to precede?
$(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>
<link rel="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>
It’s not very clear to me what you’re trying to do @Vinicius. When you click each
div
the colour of each element is changed..– BrTkCa
A big problem is that you posted a question like, "I have this layout, but I don’t know how to make it work, do it for me?" It was not a doubt, it was a request for technical support :P Set a main scope for the question, if there are more questions, create another question.... in my view this very wide
– MarceloBoni
@marceloBoni, I believe that now the question has become clearer.
– Vinicius