0
Hello. I’m trying to create an application, the idea is exactly what is found in this Theme http://klbtheme.com/kryptix/ under the title How ICOX Works.
The color of my icon is gray and the background is white. I want it to change to white and purple background. My icon is font type, so about that ok. But in addition, when you click on icon 1, I want the content to appear, and when you click on icon 2. I want you to switch to the content of 2. This is easy using css and applying/removing classes, so far ok, but the problem is in javascript.
The parts of html are:
<div class="plan-card-basic cards-flex">
<div class="plan-card-icons">
<div class="icon-visual" id="icon-financeiro">
<i class="icofont-exchange icon-white"></i>
</div>
<div class="icon-visual" id="icon-mensalidade">
<i class="icofont-money-bag icon-white"></i>
</div>
</div>
</div>
and
<div class="plan-card-text">
<div class="financeiro conteudo">
<h2>Financeiro</h2>
<p>Texto para Financeiro.</p>
</div>
<div class="mensalidade conteudo">
<h2>Mensalidade</h2>
<p>Textos para Mensalidade.</p>
</div>
</div>
I created the code below, where I can be part of what I wish is to change the colors.
var TodosIcones = document.querySelectorAll('.icon-visual');
for (var i = 0; i < TodosIcones.length; i++) {
TodosIcones[i].onclick = onTabClick;
}
function onTabClick () {
var Icon = this;
var Icones = Icon.parentNode.querySelectorAll('.icon-visual');
for (var i = 0; i < Icones.length; i++) {
if (Icon == Icones[i]) {
Icones[i].classList.add('icone-selecionado');
} else {
Icones[i].classList.remove('icone-selecionado');
}
}
}
The content class has None display to not appear, so now none appears. But I want when the first icon is clicked, this class of the first content disappears, making the content visible on the screen, and when you click the second, add the class again and remove the second class.
Someone can help me?
Thank you so much, that solved my problem.
– Graziela Kolling da Silva