Friday, May 10, 2019

javascript - input checkbox true or checked or yes




I've seen the three implementations of pre-selecting a checkbox. I started off using checked="checked" because I thought it was the "proper" way (never did like the "checked"="yes" however). I am thinking of changing to checked="true" as it seems more readable and is easier to code the JavaScript. Note that this same question applies to other attributes such as "disabled"="disabled" versus "disabled"="true". As long as I am consistent, is using "true" the preferred approach? Thank you








Answer



Only checked and checked="checked" are valid. Your other options depend on error recovery in browsers.



checked="yes" and checked="true" are particularly bad as they imply that checked="no" and checked="false" will set the default state to be unchecked … which they will not.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...