select 根据后台传来的值选中

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/BingJingforyou/article/details/83617584

js中

<script type="text/javascript">
$(document).ready(function(){  
     var key=$("#selectRefundReason").val();
     //根据值让option选中 
     $("#refundReason option[value='"+key+"']").attr("selected","selected"); 
}); 
</script>

html中

 <span>
                    <input type="hidden" id ="selectRefundReason" value="{$type}"/>
                    <select class="select" size="1" name="type" id="type" onchange="changtype('{:url('carousel/index')}')">
                        <option value="0">商铺</option>
                        <option value="1">用户</option>
                     </select>
 </span>


<input type="hidden" id ="selectRefundReason" value="{$type}"/>
隐藏后台传来的值,在js中取值

展开阅读全文

没有更多推荐了,返回首页