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

113
Visualizações
Trying to navigate to page location when selecting option from select options dropdown

so I have a select box like this with more elements being loaded in of course.

<select class="cherry-dropdown">
   <option class="cherryOption" value="#cherry_'.$rownum.'">'.$name.'</option>
</select>

And. I'm trying to use javascript to take me to the appropriate page location based off the value attribute in the option.

$('.cherry-dropdown').click(function(){
   console.log("yes");

   $('.cherryOption').click(function(){
      console.log("maybe");
      window.location=$(this).val();
   });
});

I'm getting yes from the first console.log (opening the select box to reveal the options). But when I click an option I'm not getting the maybe console.log, and thus the window.location part isn't working as well.

What am I doing wrong here...

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

0

You only actually need one event listener here, if you target the select menu itself (.cherry-dropdown) and listen for a change event instead of click, and then by passing the event as a argument to access it's value.

$(".cherry-dropdown").change(function (e) {
    console.log(e.target.value); //Returns the selected options value
    window.location = $(this).val();
});
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