Having space between string in Value of a checkbox input like Item Two
I am not able to set the checkbox to be checked.
<input type="checkbox" id="item2" name="check" value="Item Two">Item Two
$(":checkbox[value=Item Two]").prop('disabled', true);
Is there any way to fix this without changing the value of the input?
$(":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
CodePudding user response:
You must quote the value if it has spaces
$(':checkbox[value="Item Two"]').prop('disabled', true);