[英]I need to disable ONLY the checkbox that is checked after i submit the form:
This is my HTML code:这是我的 HTML 代码:
Actually I have lots more check-boxes designed as buttons to select a room(which is represented by checkbox), So all of them getting selected is very annoying.实际上,我有更多的复选框被设计为 select 一个房间(由复选框表示)的按钮,所以所有这些都被选中非常烦人。
$("form").submit(function() { $('.seat input:checkbox').prop("disabled", true); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <form name="qwer" action="/" method="post"> <ol class="block1"> <li class="row row--1"> <ol class="seats" type="A"> <li class="seat"> <input type="checkbox" id="1A" /> <label for="1A">1A</label> </li> <li class="seat"> <input type="checkbox" id="1B" /> <label for="1B">1B</label> </li> <li class="seat"> <input type="checkbox" id="1C" /> <label for="1C">1C</label> </li> <input type="submit" value="Register" /> </form>
After I check the selected checkbox and submit the form, all other checkbox-es also gets disabled.在我选中选中的复选框并提交表单后,所有其他复选框也被禁用。
You also have to add :checked
to only disable the checked checkboxes.您还必须添加
:checked
以仅禁用选中的复选框。
$("form").submit(function() { $('.seat input:checkbox:checked').prop("disabled", true); //Change here });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <form name="qwer" action="/" method="post"> <ol class="block1"> <li class="row row--1"> <ol class="seats" type="A"> <li class="seat"> <input type="checkbox" id="1A" /> <label for="1A">1A</label> </li> <li class="seat"> <input type="checkbox" id="1B" /> <label for="1B">1B</label> </li> <li class="seat"> <input type="checkbox" id="1C" /> <label for="1C">1C</label> </li> <input type="submit" value="Register" /> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.