Categories
HTML

How to toggle HTML radio button by clicking its label?

Spread the love

Sometimes, we want to toggle HTML radio button by clicking its label.

In this article, we’ll look at how to toggle HTML radio button by clicking its label.

How to toggle HTML radio button by clicking its label?

To toggle HTML radio button by clicking its label, we can put the radio button inside the label.

For instance, we write

<label>
  <input type="radio" name="mode" value="create" />
  <i>create table</i>
</label>

to put the radio button input inside the label element.

Then we can click on the label to toggle the radio button.

Conclusion

To toggle HTML radio button by clicking its label, we can put the radio button inside the label.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *