Jump to content

selecting option with jquery


jimfog

Recommended Posts

I have tried with various ways to make a selection of an option from a dropdown menu using jquery.

Here is the menu:

   <select class="dropdown">                          <option value="08:00">08:00</option>                          <option value="08:30">08:30</option>                          <option value="09:00">09:00</option>                          <option value="09:30">09:30</option>                          <option value="10:00">10:00</option>   </select>

I have tried various js codes but I cannot make it work-here is what I have tried:

$(".dropdown").prop("selected","08:30");$( ".dropdown" ).attr("selected","08:30");$(".dropdown option[value=08:30]").prop("selected");

I am trying to set(for example) the option to 08:30

Link to comment
Share on other sites

Here is the solution to it

 $('.dropdown').val('09:30');//09:30 is just an example, it could be anything
Edited by jimfog
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...