jq 指定下拉菜单 (option)某个值为选中状态

有的时候选择下拉菜单某个值提交表单后,页面的下拉菜单就变成了默认状态,为了记住选中的某个值,要把这个值设为选中状态,方法如下:
1 $("select[name='group']>option").each(function(){
2         if($(this).text() == aa){
3             $(this).attr('selected', 'selected')
4         }
5  });

 

posted @ 2017-06-14 16:55  cuculus  阅读(5045)  评论(0编辑  收藏  举报