//限制酒店主题只能选三个
                $(function(){
                var num = 0;
                $(":checkbox").each(function(){
                    $(this).click(function(){
                        num = $(":checked").length;//获取打钩的个数if (num > 3) {
                            $(this).removeAttr("checked");
                        }else{
                            if($(this)[0].checked) {
                            ++num;
                            if(num > 3) {
                                //alert("最多选择 三项 的上限已满, 其他选项将会变为不可选.");
                                $(":checkbox").each(function(){
                                    if(!$(this)[0].checked) {
                                        $(this).attr("disabled", "disabled");
                                    }
                                });
                            }
                        } else {
                            --num;
                            if(num <= 2) {
                                $(":checkbox").each(function(){
                                    if(!$(this)[0].checked) {
                                        $(this).removeAttr("disabled");
                                    }
                                });
                            }
                        }
                        }
                        
                    });
                });

 

相关文章:

  • 2022-03-07
  • 2021-10-14
  • 2022-12-23
  • 2021-04-15
  • 2022-12-23
  • 2021-12-12
  • 2021-11-22
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2022-01-23
  • 2021-12-09
  • 2021-06-16
相关资源
相似解决方案