Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!