简体   繁体   English

我只需要禁用提交表单后选中的复选框:

[英]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.

相关问题 选中复选框后,我需要启用表单(在页面加载时被禁用) - I need to enable form (it is disabled on page load) after checkbox checked 仅在选中复选框时提交表单 - Submit form only if a checkbox is checked 我需要一种表单,如果选中了表单中的复选框,然后将“提交”按钮打印页面,该表单会将一个类应用于div - I need a form that will apply a class to a div if a checkbox in form is checked then have submit button print the page 如果选中任何复选框并在未选中任何复选框时禁用它,如何启用提交按钮? - How can I enable a submit button if any checkbox is checked and disable it when none checkbox is checked? 仅在至少选中一个复选框时提交表单 - Submit form only if at least one checkbox is checked 选中复选框后如何禁用它? - How can I disable a checkbox after it is checked once? 选中表单中的任何/没有复选框时,启用/禁用提交按钮 - Enable/disable submit button when any/no checkbox in form is checked 角度:返回API的值后,直到我提交表单后,表单上的复选框才被选中 - ANGULAR: checkbox on form does not become checked when value from API is returned until I submit the form 仅当使用 javascript 选中至少一个复选框时才提交表单 - Submit form only if at least one checkbox is checked using javascript 提交表单检查,如果复选框已选中 - submit form check if checkbox is checked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM