简体   繁体   中英

Javascript: Input type radio

How can I select input type radio by just clicking the space around it?

在此处输入图像描述

You could use a<label> tag:

<input type="radio" name="box" id="box">
<label for="box">Your content here</label>

Clicking on the label toggles the input.

You should be using thelabel element. There are two ways to use it with a radio button, as shown below.

 <form> <label> <input type="radio" name="options"> <span>Option 1 - Inside Label</span> </label> <br> <input type="radio" name="options" id="button2"> <label for="button2"> <span>Option 2 - Outside Label</span> </label> </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM