2

I am using Spring MVC to create a checkbox like this:

<form:checkbox id="idVerifiable" path="verifiable"/>

It generates me:

<input id="idVerifiable" type="checkbox" value="false" name="verifiable">

If I try:

$('#idVerifiable').val("true");

It sets the value but the checkbox is not checked, how to change this to make it work?

0

3 Answers 3

3
$('#idVerifiable').prop("checked", true);
Sign up to request clarification or add additional context in comments.

1 Comment

@Jim Bolster glad I could help.
1

Try this,

$('#idVerifiable').attr("checked", true);

or

$('#idVerifiable').prop("checked", true);

Comments

0

You could do this:

$('input[name=verifiable]').attr('checked', true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.