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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.