Categories
JavaScript Answers

How to remove attribute checked from checkbox with JavaScript?

Spread the love

Sometimes, we want to remove attribute checked from checkbox with JavaScript.

In this article, we’ll look at how to remove attribute checked from checkbox with JavaScript.

How to remove attribute checked from checkbox with JavaScript?

To remove attribute checked from checkbox with JavaScript, we use the removeAttribute method.

For instance, we write

const audioCheckbox = document.getElementById("audioCheckbox");

audioCheckbox.removeAttribute("checked");

to get the checkbox with getElementById.

Then we call removeAttribute on the audioCheckbox to remove the 'checked' attribute.

Conclusion

To remove attribute checked from checkbox with JavaScript, we use the removeAttribute method.

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 *