Can someone explain this behavior:
<select id ="test">
<option value="-1">---All---</option>
<option value="1">first</option>
<option value="2">second</option>
</select>
$('#test').val(200);
Using the jQuery 1.10.1 the value of the select is null, but using jQuery 1.9.1 the value is the first option.
I think you want to try,
none
isselected
(or default selected) if the drop-down value not exists.Demo
The issue comes in
Blackberry 4.7
havingattributes.value
The change in
1.9 version
and1.10 version
arejQuery 1.9.1 hook
And jQuery 1.10 hook
Read #6932 Blackberry 4.7: .val() on empty option fails
May be in jQuery 1.9.1 first is the default option if you provide any non-existing value while jQuery 1.10.1 don't select anything in such case.
You should pass value of
option
which you wan to select to val(). 200 is a not present as value for any option.It's the fix to bug #13514, fixed in v1.10. Setting an invalid value should clear the select (which it does in v1.10+), not leave it at the default (first) option (v1.9).