扫码关注官方订阅号
1 2 3 4 5
以上是我寫的條件如果a1勾選a2~5鎖住
若a2~a5其中一個勾選則a1鎖住
我想再加一個條件但始終搞不定就是假設a2~5中有一個是勾選的(或兩個、三個、四個都是有勾選的)則a1就鎖住除非a2~5都沒有勾選則a1才會開啟
<script> $(function(){ var a1 = $("#a1"); var other = $("#a2,#a3,#a4,#a5"); a1.click(function(){ disabledBox(other,this.checked) }); other.click(function() { var r = false; other.each(function() { if(this.checked) { r = true; return false; } }) disabledBox(a1,r) }); //如a1已勾选,则#a2,#a3,#a4,#5锁住 //disabledBox(other,a1.attr('checked')) //如#a2,#a3,#a4,#5其中一个或多个已勾选,则a1锁住 other.each(function() { if(this.checked) { disabledBox(a1,true) return false; } }) }); function disabledBox(el,disabled){ el.attr("disabled", !!disabled); } </script>
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部