JavaScript – Change the Border Color of HTML Element
To change the border color of a HTML Element using JavaScript, get reference to this HTML element, and assign required color value to the element.style.borderColor
property.
In the following example, we will change the border color of HTML Element with id "myElement"
to "red"
, in JavaScript, using element.style.borderColor
property.
example.html
ADVERTISEMENT
Conclusion
In this JavaScript Tutorial, we learned how to change the border color of a HTML Element using JavaScript.