0

As title says, how can I change the selected option of a select box using jQuery?

I have something like this:

<select id="v_lenguaje" name="lenguaje">
<option value="English">English</option>
<option value="Spanish">Spanish</option>
<option value="Italian">Italian</option>
<option value="French">French</option>
<option value="Japanese">Japanese</option>
<option value=""></option>
</select>

By default it shows 'English', and what i want is after an ajax call the selected option change. I tried many codes but it doesn't worked. Thanks

Fosfor
  • 291
  • 2
  • 3
  • 15

2 Answers2

4

Try this:

var your_value='French';
$('#v_lenguaje').val(your_value);
sangram parmar
  • 7,604
  • 2
  • 20
  • 45
  • well thanks, that simple code worked well. I've been trying some longer ones and got aground there – Fosfor Sep 03 '13 at 06:15
2
$('#v_lenguaje').val('Italian');

just use like above, giving the option value

Fiddle Demo

RONE
  • 5,033
  • 8
  • 33
  • 68