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

158
Vistas
Is there a way to show an element if it has all of the classes matched from an array that is consistently having variables pushed in and out of it?

I'm creating a sorting program for DnD spells that sorts all 318 spells into 83 different categories. I have multiple arrays storing all of the information, and I know how to check if an element has a class from an array.

However, I want to sort the spells based on multiple tags at once, for example, selecting the Druid tag and the Level 9 tag would show only spells with those tags, but then deselecting Level 9 would show all of the Druid spells. The amount of tags chosen can go up or down consistently, and what I'm essentially looking for is something that can take all of the tags that are selected (pushed into an array) and check if all of those tags are classes in each div element, showing only the elements that contain all of the classes in the tag selection array. As it stands now, I've only been able to achieve it checking for the first tag I select, and then everything goes blank after I select a second class.

Here is what I've tried:

var selections = [];

function showCards(e) {
    $(".spellCards > img").hide();
    selections.push(classes[e]);
    
    for(var i = 0; i < 318; i++) {


    // I'm putting all of my attempts here at once, they weren't run at the same time.
        if(spellCard[i].classList.contains(selections)) {
            $(spellCard[i]).show();
        }

        if(spellCard[i].classList.matches(selections)) {
            $(spellCard[i]).show();
        )

        if(spellCard[i].classList.contains.every(selection)) { // First tag works
            $(spellCard[i]).show();
        )

        if(selection.every(c=>spellCard[i].classList.contains(c))) {
            $(spellCard[i]).show();
        )

        if(spellCard[i].classList.contains(classes[e])) {
            $(spellCard[i]).show();
        }  
    }
}
about 4 years ago · Juan Pablo Isaza
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