有很多时候我们需要选中下拉列表中的选项为我们数据库中保存的选项,那么如何做呢?
<input type="hidden" id="hidTypeId" value="<ww:property value='news.newsType'/>" /><!-- 隐藏域 -->
<script type="text/javascript">
$(function(){ //类型的下拉列表
if($('#hidTypeId').val() != null && ""!=$('#hidTypeId')){
var num111 = $('#hidTypeId').val();
$("#txtnewsType option[value='"+num111+"']").attr("selected", "selected");
}else{
// alert(0);
}
});
</script>