Để đặt màu viền ngoài, dùng thuộc tính outlineColor trong JavaScript. Bạn có thể chạy mã sau để học cách triển khai thuộc tính outlineColor −
Ví dụ
<!DOCTYPE html> <html> <head> <style> #box { border: 2px solid red; } </style> </head> <body> <div id = "box"> Nội dung demo </div> <br> <button type = "button" onclick = "display()">Thay đổi màu viền ngoài</button> <script> function display() { document.getElementById("box").style.outlineColor = "#FF5733"; document.getElementById("box").style.outline = "2px solid"; } </script> </body> </html>