<html:radio name="userFormList" property="sex" value="1" styleId="sex"> 男 </html:radio>
<html:radio name="userFormList" property="sex" value="2" styleId="sex"> 女</html:radio>在js中var sex = $("#sex").attr("value");
不管选男选女 都得到1,就是男,为什么啊?怎么改
<html:radio name="userFormList" property="sex" value="2" styleId="sex"> 女</html:radio>在js中var sex = $("#sex").attr("value");
不管选男选女 都得到1,就是男,为什么啊?怎么改
你再试试
var val=$('input:radio[name="userFormList"]:checked').val();
id 要做唯一 表示用
容易看懂的:
$("#sex").each(function(i,v){
if($(this).attr('checked')=='checked'){
sex = $(this).val();
return false;//return false就不执行each了
}
});