select 根據後臺傳來的值選中
阿新 • • 發佈:2018-12-08
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中取值