話說寫了幾句代碼在ie8上能正常運行,chrome和ff卻不行,朋友說這就是RP啊,郁悶!
其實功能需求是這樣的,兩個radio:男和女,一個button:重置。啟動頁面默認選中男,在用戶選擇女之后又點擊重置按鈕,需要恢復到默認狀態。
復制代碼 代碼如下:
<input type="radio" checked="checked" value="male" /><label for="hRdMale">男</label>
<input type="radio" value="female" /><label for="hRdFemale">女</label>
<button>重置</button>
復制代碼 代碼如下:
$("#reSet").click(function() {
$("input[name='sex']:first").attr("checked",true);
});
復制代碼 代碼如下:
$("input[name='sex']:first").prop("checked",true);
新聞熱點
疑難解答
圖片精選