Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default checking a checkbox

Tags:

html

Is there a difference between these two ways of default checking a checkbox:

document.getElementById(checkboxId).defaultChecked = checked;

vs

document.getElementById(checkboxId).checked = checked;
like image 727
Victor Avatar asked Mar 15 '12 16:03

Victor


1 Answers

defaultChecked is the default state, checked is the current state.

If you change defaultChecked and then press a <input type="reset"> then the checkbox should reset to the state specified in the defaultChecked property.

If you change checked, then the state will change immediately.

like image 173
Quentin Avatar answered Nov 13 '22 11:11

Quentin