jquery 根据值设置radio选中 prop

<input name="rbsex" id="man_radio" type="radio" value="1" checked="checked" /><label>男</label> 

<input name="rbsex" id="woman_radio" type="radio" value="0" />女

var sex = result.resultContent.gender;

$(":radio[name='rbsex'][value='" + sex + "']").prop("checked", "checked");

其中prop是重点,使用attr不行。

猜你喜欢

转载自my.oschina.net/lhuif/blog/1631316