如何实时的把checkbox设成false
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"><head><title>新建网页</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="description" content="" /><meta name="keywords" content="" /><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(function () { $('input[name="ck"]').change(function() { var count = 0; $('input[name="ck"]').each(function () { if($(this).attr('checked') == true){ count++; } if(count == 3) $('input[name="ck"]').attr('disabled',true); }) })})</script><style type="text/css"></style></head> <body> <input type="checkbox" name="ck" value="a"/>a <input type="checkbox" name="ck" value="b"/>b <input type="checkbox" name="ck" value="c"/>c <input type="checkbox" name="ck" value="d"/>d <input type="checkbox" name="ck" value="e"/>e <input type="checkbox" name="ck" value="f"/>f </body></html>$(document).ready( function() { $("input[name='ck[]']").click( function() { var o = $("input[name='ck[]']"); if (o.filter(":checked").length == 3) o.not(":checked").attr("disabled", "disabled"); else o.not(":enabled").removeAttr("disabled"); });});
[解决办法]
$(function () { $('input[name="ck"]').click(function() { if($('input[name="ck"]:checked').size()==3)$('input[name="ck"]').not(':checked').attr('disabled',true); else $('input[name="ck"]:disabled').attr('disabled',false); })})
[解决办法]
浮动层+lightbox而已,参考
lightbox实现的checkbox联动