87,992
社区成员
发帖
与我相关
我的任务
分享<div id="gridview">
<input type="checkbox" checked="checked" value="1"/>
<input type="checkbox" checked="checked" value="1"/>
<input type="checkbox" checked="checked" value="1"/>
<input type="checkbox" value="1"/>
<input type="checkbox" value="2"/>
<input type="checkbox" value="3"/>
</div>$(function(){
$('#gridview :checkbox:not(:checked)').attr("disabled",function (){return $(this).val()!=1 && $(this).val()!=2;});
}); $(function () {
var max = 3, cbs = $('#gridview :checkbox');//gridview改为你的GridView的ID
cbs.click(function () {
if (cbs.filter(':checked').size() >= max) cbs.filter(':not(:checked)').attr('disabled', true);
else cbs.filter(':disabled').attr('disabled', false);
});
});
$("#gvid :not(:checked)").each(function(i){//未选中的
alert($(this).attr("id"));
});
$(".checkbox的类名 :checkbox").each(function() {
if ($(this).is(":checked") && $(this).attr("disabled") == false) {
//被选中的
}