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

101
Visualizações
How to add a filter search bar in JS

const sounds = [
  'Jason',
  'lil Jon',
  'mario',
  'TwoClock',
  'beep boppy',
  'Dixon Cider',
  'Baldy',
  'PK Fire',
  'look Eye',
  'Show up'
];

sounds.forEach((sound) => {
  const btn = document.createElement('button');
  btn.classList.add('btn'); // sound button formula
  btn.innerText = sound;
  btn.addEventListener('click', () => {
    // stopSongs();
    document.getElementById(sound).play();
  });

  document.getElementById('buttons').appendChild(btn);
});

//#19 stops sound from playing when you click on another button


//adding a filter for our search
<h1>Dr s</h1>
<h2>Sound board</h2>

<!--Filter-->

I tried looking up and could not find a way to add a filter search for buttons. I know it should be a function just struggling on how to set it up.

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

0

This might be your solution, you forgot to add }) to the end of one of your functions. Your code should work now!

const sounds=[
'Jason',
'lil Jon',
'mario',
'TwoClock',
'beep boppy',
'Dixon Cider',
'Baldy',
'PK Fire',
'look Eye',
'Show up'
];

sounds.forEach((sound) => {
  const btn = document.createElement('button');
  btn.classList.add('btn');
  btn.innerText = sound;

  btn.addEventListener('click', () =>{

    document.getElementById('buttons').appendChild(btn); 
    }); // <= You forgot this
});
<div id="buttons">

</div>

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