-1

I am trying to make a script which somehow will check a checkbox (but not uncheck it if it is already checked). Is there a button / shortcut which will check a checkbox? (Clicking will uncheck it if it is checked, so will tab + space) Is there a way of only checking it (does nothing if it is already checked)

I hope this is clear enough, I need a way of checking a checkbox which won't uncheck it if it is already checked.

4

1 回答 1

0

您可以在选中时禁用该复选框。

$(document).ready(function() {
  $('#id1').change(function() {
        $("#id1").attr("disabled", true);
    });

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<input type="checkbox" id="id1"> Checkbox

于 2019-02-21T16:26:51.380 回答