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

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

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 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