How do you select a particular option in a SELECT element in jQuery?

前端 未结 21 1972
Happy的楠姐
Happy的楠姐 2020-11-22 10:55

If you know the Index, Value or Text. also if you don\'t have an ID for a direct reference.

This, this and this are all helpful answers.

Example markup

21条回答
  •  一生所求
    2020-11-22 11:26

    There are a number of ways to do this, but the cleanest approach has been lost among the top answers and loads of arguments over val(). Also some methods changed as of jQuery 1.6, so this needs an update.

    For the following examples I will assume the variable $select is a jQuery object pointing at the desired

    提交评论

提交回复
热议问题