Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

376
Visualizações
When I change the filter, all values change. I would like only the value of the 'block-value' HTML to change

I try to display valueToday[1] for my second element 'block-value' and i try to display valueToday[0] for my first element 'block-value'. But divs[i].querySelector(class).style.display = "" is not working My filter called for each element :

let values = document.querySelectorAll('.value-h6');
let valueToday = document.querySelectorAll('.value-today');
let valueMonth = document.querySelectorAll('.value-month');
let valueYear = document.querySelectorAll('.value-year');
let divs = document.querySelectorAll('block-value');

function init() {
  // Clear data
  for (let i = 0; i < values.length; i++) {
    values[i].style.display = "none";
  }
  for (let i = 0; i < valueToday.length; i++) {
    valueToday[i].style.display = 'block';
  }
}
// user is coming, the default value is the dailyValue
init();

function today() {
  init();
}

function month() {
  for (let i = 0; i < values.length; i++) {
    values[i].style.display = "none";
  }
  for (let i = 0; i < valueMonth.length; i++) {
    valueMonth[i].style.display = 'block';
  }
}

function year() {
  for (let i = 0; i < values.length; i++) {
    values[i].style.display = "none";
  }
  for (let i = 0; i < valueYear.length; i++) {
    valueYear[i].style.display = 'block';
  }
}
<div class="ps-3 block-value" id="0">
  <h6 class="value-h6 value-today">23%</h6>
  <h6 class="value-h6 value-month">24%</h6>
  <h6 class="value-h6 value-year">25%</h6>
</div>

<div class="ps-3 block-value" id="1">
  <h6 class="value-h6 value-today">300</h6>
  <h6 class="value-h6 value-month">34</h6>
  <h6 class="value-h6 value-year">23</h6>
</div>

<li><button class="dropdown-item filter-btn filter-auj" onclick="today()">Aujourd'hui</button></li>
<li><button class="dropdown-item filter-btn filter-mois" onclick="month()">Ce mois</button></li>
<li><button class="dropdown-item filter-btn filter-annee" onclick="year()">Cette année</button></li>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try display = 'none' (https://www.w3schools.com/jsref/prop_style_display.asp#:~:text=The%20display%20property%20also%20allows,its%20original%20position%20and%20size.) W3schools has excellent documentation for these things ;-)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda