【jquery】ajax 动态 改变 select下拉框选中的值

//JS
<
script type="text/javascript> //ajax动态给添加原料的【商品名称】下拉框绑定selected属性 $("#origin_code").find("option").each(function(index,dom){ if($(this).val() == msg.data.origin_code){ $(this).attr("selected","selected"); return false; } }) </script>

 

//html

<select name="ajax[origin_code2]" id="origin_code" class="form-control" >
                          <option value="">请选择原料名称</option>
                      <volist name="origin_arr" id="vo">
                          <option value="{$vo.origin_code}" ref="{$vo.origin_unit}" >{$vo.origin_name}</option>
                         </volist>
                      </select>

 

posted @ 2018-07-25 09:55  PHP急先锋  阅读(1189)  评论(0编辑  收藏  举报