How to reset an input control’s border color with JavaScript?

Sometimes, we want to reset an input control’s border color with JavaScript.

In this article, we’ll look at how to reset an input control’s border color with JavaScript.

How to reset an input control’s border color with JavaScript?

To reset an input control’s border color with JavaScript, we can use the removeProperty method.

For instance, we write:

<input style='border-color: red'>

to add an input with a red border.

Then we write:

setTimeout(() => {
  document.querySelector('input').style.removeProperty('border-color');
}, 2000)

to select the input with querySelector.

Then we remove the border-color CSS property from the styles with removeProperty.

We put it in the setTimeout callback to remove the border in 2 seconds.

Conclusion

To reset an input control’s border color with JavaScript, we can use the removeProperty method.