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

299
Visualizações
Javascript: how to function if class exists or change

Thank you, everyone! I am keep going design my game with Javascript.

There is box, id called 'box1'. Also, there is a hidden button. I have a function to change the box1 class.

I want to change the visibility if the box1 has the class "glow". In fact, I am planning to check 9 boxes class. Therefore, I may use && for "if" condition.

$(document).ready(function() {
  if (document.$('#box1').classList.contains('.glow')) {
    $(".btn-warning").css('visibility', 'visible');
}});
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

something like you can design your code

You have a 9 blocks with its like box1, box2, so on

Loops through get all class nodes

$("div[id^='box']").foreach(function(){
  if($(this).hasClass(".glow"))
  {
  // your logic
  $(".btn-warning").css('visibility', 'visible');
  }
}

I hope this will work for you

about 4 years ago · Santiago Trujillo Relatório

0

Thank you everyone for your comments. I change my logic.

I finish the code myself.

gameboxsize is the div for 9boxes.

setInterval(function() {
  var gamebox = document.getElementById('gameboxsize');
  var nodesSameClass = gamebox.getElementsByClassName('glow');
  console.log(nodesSameClass.length);
  var winNum = nodesSameClass.length;

  if (winNum === 9) {
    $(".btn-warning").css('visibility', 'visible');
  }
});
about 4 years ago · Santiago Trujillo 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