当前位置:嗨网首页>书籍在线阅读

22-问题

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

10.5.1 问题

你需要用一个切换开关(这里是另一个复选框)选中和反选所有复选框。此外,如果单独选中某些(或者所有)复选框,切换动作应该自动变换它们的状态:

<fieldset>
   <legend>Reasons to be happy</legend>
   <input name="reasons" id="toggleAllReasons" type="checkbox" class="toggle" />
   <label for="toggleAllReasons" class="toggle">Select All</label>
   <input name="reasons" id="iwokeup" type="checkbox" value="iwokeup" />
   <label for="iwokeup">I woke up</label>
   <input name="reasons" id="health" type="checkbox" value="health" />
   <label for="health">My health</label>
   <input name="reasons" id="family" type="checkbox" value="family" />
   <label for="family">My family</label>
   <input name="reasons" id="sunshine" type="checkbox" value="sunshine" />
   <label for="sunshine">The sun is shining</label>
</fieldset>