Categories
JavaScript Answers

How to clear radio button in JavaScript?

Spread the love

Sometimes, we want to clear radio button in JavaScript.

In this article, we’ll look at how to clear radio button in JavaScript.

How to clear radio button in JavaScript?

To clear radio button in JavaScript, we set its checked property to false.

For instance, we write

document.querySelector('input[name="Choose"]:checked').checked = false;

to select the checkbox we want to uncheck with querySelector.

And then we set its checked property to false to clear it.

Conclusion

To clear radio button in JavaScript, we set its checked property to false.

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 *