Sometimes, we want to change textbox border color using JavaScript.
In this article, we’ll look at how to change textbox border color using JavaScript.
How to change textbox border color using JavaScript?
To change textbox border color using JavaScript, we can set the style.border
property of the input to red.
For instance, we write:
<input type="text" />
to add an input.
Then we write:
document.querySelector("input").style.border = "1px solid red";
to select the input with querySelector
.
And we set the style.border
property of it to '1px solider red'
to add a red border to it.
Conclusion
To change textbox border color using JavaScript, we can set the style.border
property of the input to red.