Home > Blockchain >  Javascript: Input type radio
Javascript: Input type radio

Time:04-11

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

enter image description here

CodePudding user response:

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.

CodePudding user response:

You should be using the label 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>

  • Related