【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>

猜你喜欢

转载自www.cnblogs.com/xuzhengzong/p/9364263.html
今日推荐