更新时间:2023-10-08 23:35:52
这实际上是一个简单的解决方案,下次仔细思考问题并先尝试一下,你会发现它并不复杂!这应该工作< li >
< h5 class = booking-filters-title > Abc < / h5 >
< div class = 复选框 >
< label >
< input id = chkAny class = i-check runat = server type = 复选框 checked / > 所有
< / label >
< / div >
< div 类 = 复选框 > ;
< label >
< input id = chkOne onclick = chkMe(); class = i-check runat = server type = 复选框 选中/ > 1
< / label >
< / div >
<div class = 复选框 >
< label >
< input id = chkTwo onclick = chkMe(); 类 = i-check runat = 服务器 类型 = 复选框 已选中/ > 2
< / label >
< / div >
< / li >
< 脚本 >
function chkMe()
{
if(document.getElementById(chkOne)。checked == true&& document.getElementById(chkTwo)。checked == true)
document.getElementById(chkAny)。checked = true;
else
document.getElementById(chkAny)。checked = false;
}
< / script > 跨度>
Hi
i am using three input whose type=checkbox in my design, now the check boxes are like this
All
1
2
All is checked by default. What i want is that when i select either 1 or 2 i want the "All" option to be unchecked.
My HtMl code:
<li>
<h5 class="booking-filters-title">Abc</h5>
<div class="checkbox">
<label>
<input id="chkAny" class="i-check " runat="server" type="checkbox" />All
</label>
</div>
<div class="checkbox">
<label>
<input id="chkOne" class="i-check" runat="server" type="checkbox" />1
</label>
</div>
<div class="checkbox">
<label>
<input id="chkTwo" class="i-check" runat="server" type="checkbox" />2
</label>
</div>
</li>
I am using Bootstrap and I want it to be done via java script.
Regards
Syed
It's actually a simple solution, next time think through the problem and attempt something first and you will discover it's not that complicated! This should work<li> <h5 class="booking-filters-title">Abc</h5> <div class="checkbox"> <label> <input id="chkAny" class="i-check " runat="server" type="checkbox" checked/>All </label> </div> <div class="checkbox"> <label> <input id="chkOne" onclick="chkMe();" class="i-check" runat="server" type="checkbox" checked/>1 </label> </div> <div class="checkbox"> <label> <input id="chkTwo" onclick="chkMe();" class="i-check" runat="server" type="checkbox" checked/>2 </label> </div> </li> <script> function chkMe() { if(document.getElementById("chkOne").checked == true && document.getElementById("chkTwo").checked == true) document.getElementById("chkAny").checked = true; else document.getElementById("chkAny").checked = false; } </script>