当复选框的值属性中包含 Space 时无法设置复选框的属性

Not Able to Set Attribute of a Checkbox When It has Space in It's Value Attribute

复选框 输入的 中的字符串之间有 space,例如 Item Two 我无法设置要选中的复选框。

<input type="checkbox" id="item2" name="check" value="Item Two">Item Two
$(":checkbox[value=Item Two]").prop('disabled', true);

有没有办法在不改变输入值的情况下解决这个问题?

$(":checkbox[value=ItemOne]").prop("checked", "true");
$(":checkbox[value=Item Two]").prop('disabled', true);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" id="item1" name="check" value="ItemOne">Item One
<input type="checkbox" id="item2" name="check" value="Item Two">ItemTwo

如果值有空格,您必须引用该值

$(':checkbox[value="Item Two"]').prop('disabled', true);