Change the width, style and color of the top border of a <div> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderTop

Description

Change the width, style and color of the top border of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDiv {/*  w w w . j  a va2s.  co m*/
    border: thick solid blue;
}
</style>
</head>
<body>

<div id="myDiv">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Change top border</button>

<script>
function myFunction() {
    document.getElementById("myDiv").style.borderTop = "thin dotted red";
}
</script>

</body>
</html>

Related Tutorials