實現的需求就是單選按鈕點擊取消,在數據加載以後執行,寫的方法就是 $().ready(function(){ //do something })this
$().ready(function(){
$("input:radio").click(function(){
var checkedState = $(this).attr('checked');//記錄當前選中狀態
console.log(checkedState)
$(this).attr('checked',true);//2.
if(checkedState == 'checked'){
$(this).attr('checked',false); //3.
}
});
})複製代碼