js_选中指定单选

html

<input name="lx" id="male" type="radio" value="male" checked  >
<span  >span>

<input name="lx" id="female" type="radio"  value="female" > 
<span>span>

js

/*选中radio */
function selectRadio(name,id){
    $("input[name="+name+"]").each(function(){
        $(this).prop("checked",false);
    });
    $("#"+id).prop("checked",true);
}

选中:男
selectRadio("lx","male")

你可能感兴趣的:(javascript)