Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda