React Label

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

<label>
  Name:
  <input type="text" name="name" />
</label>

HTML長這樣
label可以包住input,也可以不包
包住input就不用給for值了喔
記得for對應的是id
radio的群組是用name來群組

There are 2 methods of labelling a form control using the HTML label element. You can wrap the control inside the label element or you can include the for attribute on the label element, which has a value matching the id value of the control it is intended to label.

HTML5 Accessibility Chops: form control labeling


然後React版本的for要用 htmlFor
然後點擊事件要綁在input上面,不能綁在label