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

前端 未结 21 1767
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:21

    None of the methods above provided the solution I needed so I figured I would provide what worked for me.

    $('#element option[value="no"]').attr("selected", "selected");
    

提交回复
热议问题