jQuery(":radio[value=${user.gender}]").attr("checked",true);一句就搞定,而用平常的
<td class="px10"><input type="radio" name="sex" id="radio" value="NONE" <c:if test="${sex=='NONE'}"><c:out value="checked"/></c:if>/>
保密
<input type="radio" name="sex" id="radio" value="MAN" <c:if test="${sex=='MAN'}"><c:out value="checked"/></c:if>/>
男
<input type="radio" name="sex" id="radio" value="WOMEN" <c:if test="${sex=='WOMEN'}"><c:out value="checked"/></c:if> />
女
</td>
简化性别选择:jQuery与JSP示例
本文介绍了一种使用jQuery简化JSP页面中性别选项预填充的方法。通过对比传统的JSP+C标签的方式,展示了jQuery实现相同功能更为简洁高效。此方法不仅减少了代码量,还提高了页面加载速度。

被折叠的 条评论
为什么被折叠?



