2014-02-28 04:37 阅读 63


In the image below, if I click either male or female text, I want the checkbox to be checked. How can I do that?

enter image description here

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    dpwh11290 dpwh11290 2014-02-28 04:47

    Second option is to wrap both checkbox and text in a label. It will work too:

        <input id="male_checkbox" name="gender" type="checkbox" value="male" /> Male
    点赞 评论 复制链接分享
  • doushan2224 doushan2224 2014-02-28 04:40

    You need to use label with for attribute:

    <label for="male_checkbox">Male</label>
    <input id="male_checkbox" name="gender" type="checkbox" value="male" />
    点赞 评论 复制链接分享
  • douliang4858 douliang4858 2014-02-28 04:42

    <input type="checkbox" name="male" id="male" value="male"><label for="male">Male</label>

    This will allow the user to click either the name or the checkbox

    Do the same for female.

    点赞 评论 复制链接分享