
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the color of an elements border with JavaScript?
To set the color of an element's border in JavaScript, use the borderColor property.
Example
You can try to run the following code to learn how to set a color of an element's border −
<!DOCTYPE html> <html> <head> <style> #box { height: 300px; width: 200px; border: thick dashed yellow; } </style> </head> <body> <div id="box"> <p>DEMO TEXT</p> <p>DEMO TEXT</p> <p>DEMO TEXT</p> <p>DEMO TEXT</p> </div> <br> <button type="button" onclick="display()">Set new color of border</button> <script> function display() { document.getElementById("box").style.borderColor = "green"; } </script> </body> </html>
- Related Questions & Answers
- How to set the color of the left border with JavaScript?
- How to set the color of the right border with JavaScript?
- How to set the color of the top border with JavaScript?
- Set the color of the border with CSS
- How to set border width, border style, and border color in one declaration with JavaScript?
- How to set the color of the bottom border in JavaScript DOM?
- How to set the border color of certain Tkinter widgets?
- How to set the color of the outline around an element with JavaScript?
- How to set the width of an element's border with JavaScript?
- How to set the style of an element's border with JavaScript?
- How to set the style of the left border with JavaScript?
- How to set the width of the bottom border with JavaScript?
- How to set the style of the bottom border with JavaScript?
- How to set the width of the top border with JavaScript?
- How to set the width of the left border with JavaScript?
Advertisements