1 function addCheckBox(){//JS生成的checkbox 2 var html=''; 3 html+='<input type="checkkbox" />'; 4 html+='<input type="checkkbox" />'; 5 html+='<input type="checkkbox" />'; 6 $('#log_window').html(html); 7 } 8 9 function checkedOnlyOne() { 10 //if ($(this).is(":checked")) { 11 // $("#log_window input[type='checkbox']").attr("checked", false); 12 // $(this).attr("checked", true); 13 //} //一般情况下用这个就可以 14 $(document).ready(function(){ //JS生成的checkbox要加上这句 15 $('#log_window').find('input[type=checkbox]').bind('click', function () { 16 $('#log_window').find('input[type=checkbox]').not(this).attr("checked", false); 17 }); 18 }); 19 } 20 //html 21 <div id="log_window"></div>