jQuery 1.10.1 setting non existing value on select

前端 未结 3 2028
小鲜肉
小鲜肉 2021-01-13 07:16

Can someone explain this behavior:


                        
    
提交评论

  • 2021-01-13 07:30

    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.

    0 讨论(0)
  • 2021-01-13 07:41

    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.

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

    0 讨论(0)
  • 提交回复
    热议问题