Set the color of the top and bottom border to green, and left and right border to purple, of a <div> element - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderColor

Description

Set the color of the top and bottom border to green, and left and right border to purple, of a <div> element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {//from w w  w .  j av  a2s.  com
    border: thick solid blue;
}
</style>
</head>
<body>

<div id="myDiv">This is a div.</div>
<br>
<button type="button" onclick="myFunction()">Change color of the four borders</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.borderColor = "green purple";
}
</script>

</body>
</html>

Related Tutorials