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

112
Visualizações
Filtering displayed data based on the data attribute

I have an input field and a bunch of containers that contain multiple data attributes, how do I dynamically show/hide the containers based on the value of the input? For example, if the value of the search input is "frontend" it should only display containers that have data-role: frontend, the same goes for the rest.

<input type="search">

    <div class="container" data-role="Fullstack" data-level="Midweight" data-languages="JavaScript Rub" data-tools="Sass">

     <div></div>

    </div>

    <div class="container" data-role="Backend" data-level="Junior" data-languages="Ruby" data-tools="RoR">

     <div></div>

    </div>

I'd like it to be in jQuery.

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

0

First make all of them hidden, for instance with visibility property of css then on input's blur/change call a function like this

$('div[id^=proto_]').filter('div[data-role=frontend]').css('visibility','visible');

Also you need to add an id to all of the elements the get them. in my example I added some id's starting with proto_.

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