How to set default status using javascript?

I use this in jQuery

$('#RememberMe').attr('checked', true); 

but I can’t remember how to do this in Javascript. I thought that

document.getElementById("RememberMe").value = "True"; 

will work, but it’s not, it changes the value, but does not create a visual html check.

I am trying to check the default box. here is the html

<input id="RememberMe" name="RememberMe" type="checkbox" value="false" />   
+5
source share
1 answer

To change the state flag , do the following:

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

If you need to change the checkbox value , if you use an element input:

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

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

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

All Articles