// 页面隐藏域的值 var platIdVal = $("#platIdVal").val(); // 如果platIdVal为空,说明没有勾选单选框 if(platIdVal==null || platIdVal == ''){ // 默认选中平台单选框的第一个 $(".admin-content-task input:first").attr("checked",true); }else{ $(".admin-content-task input[value="+ platIdVal +"]").attr("checked",true); }
<input type="hidden" id="platIdVal" value="${map.platIdVal?if_exists}"/>
<!--radio域、部分代码--> <ul class="am-list admin-content-task"> <#if apiInfos?exists> <!-- N个一行,使用FreeMarker的chunk()函数进行 --> <#list apiInfos?chunk(7) as row> <div style="clear: both; border: 0px solid green;"> <!-- 行序号 --> <div class="platIdInnerDiv" style="width: 1%;"> ${row_index + 1}.</div> <!-- 行内子div,用来存放platId复选框 --> <#list row as obj> <div class="platIdInnerDiv"> <input type="radio" id="platId${row_index}${obj_index}" name="platId" value="${obj.platId}" class="platIdCls" /> <label for="platId${row_index}${obj_index}">${obj.platId}</label> </div> </#list> </div> </#list> </#if> </ul>
map.put("platIdVal", platId);
request.setAttribute("map", map);
Jquery默认选中单选框radio第一个、选中指定值的单选框
原文地址:http://blog.csdn.net/limenghua9112/article/details/46043421