How to set default checkbox status with javascript?

javascript, jquery

Solution

To change checkbox state try this:

document.getElementById("RememberMe").checked = true;

If you need to change the value of checkbox as an `input` element use:

document.getElementById("RememberMe").value = "New Value";

However, you can set default value and state in HTML markup:

<input id="RememberMe" name="RememberMe" type="checkbox" value="The Value" checked="checked" /> 

Problem

I am used to doing this in jQuery ``` $('#RememberMe').attr('checked', true); ``` but I can't remember how to do it in Javascript I thought that ``` document.getElementById("RememberMe").value = "True"; ``` would work, but it doesn't, it changes the value but does not create the visual check on the html. I am trying to set the checkbox to on by default. here is the html ``` <input id="RememberMe" name="RememberMe" type="checkbox" value="false" /> ```

Original source