0
I need to change the color only of the element that was clicked, in case change the background color of the div - the same and cloned several times creating more div in html depending on how much is needed - in all cases that I did using Parent and siblings did not get success , all remain changing color, need only the clicked div change color, and the others remain with the standard color.
**Icon**
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<i class="taskIcon glyphicon glyphicon-chevron-down">
</i>
</a>
<div class="panel-group" id="accordion">
<div class="panel panel-default task">
<div class="panel-heading taskToDo">
<span class="col-sm-8 taskTitle">
<span class="checkTask"><i class="fa fa-check" aria-hidden="true"></i></span>
descricao
</span>
</div>
</div>
</div>
JS
$(".taskIcon").on("click", function () {
$(this).toggleClass("glyphicon-chevron-down").toggleClass("glyphicon-chevron-up");
$(".boxTipoDeAtividade").hide();
$(".taskAtividades").addClass("glyphicon-chevron-down");
**$(".taskToDo").addClass("taskToDoBackground");**
});
CSS
.taskToDoBackground{
background-color: #efefef !important;
}
Tried passing parameters? Type:
function (numerar por exemplo os botões )
theonClick
? 1 onclick button - change color of specific parameter.– Peaga SiCK
Marcelo, you can show the parent element of
<div class="taskToDo">
?– Sergio
posted the rest
– Marcelo Batista
Now he’s even more confused. Is there any common father among
<a>
and. taskToDo
? this HTML repeats itself several times on the right page?– Sergio
yes repeat several times
– Marcelo Batista
I saw that you removed the other question. I was going to answer but it’s gone :)
– Sergio
Is there any common father among
<a>
and. taskToDo
that obeys this repetition?– Sergio
I was going to rephrase, however I thought it didn’t fit properly, sorry
– Marcelo Batista