Skip to content

再谈 radio & checkbox #205

Description

@teazean

radio & checkboxform 都是可以出现多次相同 name 的输入控件,他们的差异在于:

  • radio:多个相同 name 的情况下(单选组),radio 只能选择一个,当选择其中一个时,其他的会取消选择,但是真正触发 change 只有有交互的那个,其他的不触发 change 事件。
  • checkbox: 多个相同 name 的情况下(多选组),每一个 checkbox 都可以独立选择,独立触发 change 事件。

radio 的应用场景其实只有 radio group,只有多个选择情况下才有意义,有一个缺点,但你选中一个 radio 的时候,是没法清空选择的。

<input type="radio"><input type="checkbox"> 不设置 value 的情况下,取得的 input.value 均是默认值 on

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions