douzi115522
2014-02-28 04:37 阅读 63
已采纳

如何使用php单击文本选中复选框?

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:

    <label>
        <input id="male_checkbox" name="gender" type="checkbox" value="male" /> Male
    </label>
    
    点赞 评论 复制链接分享
  • 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.

    点赞 评论 复制链接分享

相关推荐