how to give colored borders to an html element using javascript code example

Example 1: javascript for border color

var getColor = prompt("Choose your color ", "Enter the  color ");
 var color;
 var el = document.getElementById("color");
 el.innerHTML = "Whatever paragraph message.";
 if (getColor =="Yellow" || getColor =="yellow" || getColor =="YELLOW"){
     color = "#FFFF66";
     el.style.borderColor = color;
 }

Example 2: how to change input border color with js

document.getElementById("fName").className = document.getElementById("fName").className + " error";  // this adds the error class

document.getElementById("fName").className = document.getElementById("fName").className.replace(" error", ""); // this removes the error class

Tags:

Css Example