3
I need to change my code so that when I click on a div, the parent div changes its css. For example I click on an input inside the div, and the parent div changes its css.
I have the following code:
$(document).ready(function(){
$(".tel, .email, #nome, .col-lg-6").click(function(){
// A div é a com a classe .col-lg-6
// O código que sei é esse $(this).css({"background-color":"red"}); mas preciso de um código que mude o css daquela div, que pelo qual possui o objeto que foi clicado.
}
}
$(".tel, .email, #nome, .col-lg-6").click(function(){
$(this).css("background-color","red");// código ao ser alterado
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-lg-6">
<div class="email">Email</div>
<div class="teste1">teste1</div>
<div class="email">email</div>
<div class="teste2">teste2</div>
<div class="tel">Tel</div>
<div class="teste3">teste3</div>
</div>
<div class="col-lg-6">
<div class="email">Email</div>
<div class="teste1">teste1</div>
<div class="email">email</div>
<div class="teste2">teste2</div>
<div class="tel">Tel</div>
<div class="teste3">teste3</div>
</div>
There are several Divs with the same class. If I used this code it would change the css of all Divs with the class "col-lg-6".
– Carlos Henrique
What I need is that of several Ivs that in one element of it is clicked, only that div that has that element clicked, change its css, that is, I have several Ivs with the same class, and each div has a same element with different name. I need only that div that has the clicked element change its css.
– Carlos Henrique
I edited the answer, see now
– Laércio Lopes